Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C by f3ex ( 16 years ago )
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct _ClientAccount _ClientAccount;
struct _ClientAccount
{
 char Name[30];
 float Balance;
 char INN[13];
 char Email[20];
 _ClientAccount *next;
 _ClientAccount *prev;
};

_ClientAccount *cur=0; //, *first=NULL;

int newitem(char *name, float Balance, char *INN, char *Email)
{
    _ClientAccount *tmp;
    tmp = (_ClientAccount*)malloc(sizeof(_ClientAccount));
    if (tmp==0){printf("nНевозможно выделить память");}
    strcpy(tmp->Name,name); 
    tmp->Balance=Balance;
    strcpy(tmp->INN,INN);                  
    strcpy(tmp->Email,Email); 


//    tmp->next=cur->next;
//    tmp->prev=cur->prev;
     
    if(cur==0) //Добавление первого элемента
    {
      cur=tmp;
//      cur->next=tmp;
      cur->prev=0;
      cur->next=0;
     }

     if(cur!=0) //Добавление элементов
    {
//         cur=tmp;
//       cur->next=tmp;
//         cur->next->prev=cur;
//       cur->prev->next=cur;
        tmp->prev=cur;
        cur->next=tmp;
        tmp->next=0;
        cur=tmp;
    }
    
    
  return 0;
}


int main() {

    char q1[]="qwe1",w[]="inn",e[]="email";
    newitem(q1,1,w,e);
    char q2[]="qwe2",w1[]="inn1",e1[]="email1";
    newitem(q2,2,w1,e1);
    
    printf("%sn",cur->Name);
    printf("%sn",cur->prev->Name);
    printf("%sn",cur->Name);


    char q3[]="qwe3",w2[]="inn2",e2[]="email2";
    newitem(q3,2,w2,e2);
    printf("%sn",cur->Name);
    printf("%sn",cur->prev->prev->Name);

    
    
    
    
    return 0;

}

 

Revise this Paste

Your Name: Code Language: