hi there I am a newbie
could you please convert this c++ program into a C program
I really need help.. please do if you canCode:#include<iostream.h> #include<conio.h> #include<stdio.h> #define NULL 0 class address { private: struct info { char nickname[20],name[30],mail[35]; int id_no;long int phone; info *next; }; info *head,*temp,*disp; public: address(); ~address(); void addrecord(); void deleterecord(); void modifyrecord(); void displayrecord(); }; void address::address() { head=NULL; temp=NULL; disp=NULL; } address::~address() { while(head!=NULL) { info *t1; t1=head; head=head->next; delete t1; } } void address::addrecord() { info *add; char proceed='y'; while(proceed=='y') { clrscr(); add=new info;gotoxy(25,10); cout<<"\n\tEnter item entry number :"; cin>>add->id_no; fflush(stdin); cout<<"\n\t\tEnter name :"; scanf("%s",add->name); fflush(stdin); cout<<"\n\t\tEnter e-mail address :"; scanf("%s",add->mail); fflush(stdin); cout<<"\n\t\tEnter phone number :"; cin>>add->phone; fflush(stdin); cout<<"\n\t\tEnter nickname :"; scanf("%s",add->nickname); fflush(stdin); if(head==NULL) { head=add; add->next=0; temp=add; } else { temp->next=add; add->next=NULL; temp=add; } cout<<"\n\n\t\tWant to proceed[y/n]:"; cin>>proceed; fflush(stdin); } } void address::deleterecord() { info *del; int tex,present=0;clrscr(); if(head==NULL) { gotoxy(25,20); cout<<"\n No record found to delete";getch(); return; } gotoxy(25,20); cout<<"\n Enter item number to delete:"; cin>>tex; fflush(stdin); for(del=head;del!=NULL;del=del->next) { if(del->id_no==tex) { if(head->id_no==tex) { del=head; head=head->next; delete del; return; } else { for(disp=head;disp!=NULL;disp=disp->next) if(disp->next==del) { disp->next=del->next; delete del; if(disp->next==NULL) temp=disp; return; } } } } if(present==0) cout<<"\n No such entry found"; else cout<<"\n Entry deleted.";getch(); } void address::modifyrecord() { info *modify; int tex,present=0;clrscr();gotoxy(25,20); cout<<"\n Enter entry number to edit "; cin>>tex; fflush(stdin); for(modify=head;modify!=NULL;modify=modify->next) { if(modify->id_no==tex) { cout<<"\n\t\t Enter nickname to change:"; scanf("%s",modify->nickname); fflush(stdin); cout<<"\n\t\t Enter name to change:"; scanf("%s",modify->name); fflush(stdin); cout<<"\n\t\t Enter e-mail to change:"; scanf("%s",modify->mail); fflush(stdin); cout<<"\n\t\t Enter phone number to change"; cin>>modify->phone; fflush(stdin); return; } } if(present==0) cout<<"\n Entry not found";getch(); } void address::displayrecord() { if(head==NULL) { clrscr(); cout<<"\n No record to display";getch(); return; } for(disp=head;disp!=NULL;disp=disp->next) { clrscr();gotoxy(25,20); cout<<"\n\t entry no:"<<disp->id_no; cout<<"\n\t nickname:"<<disp->nickname; cout<<"\n\t name:"<<disp->name; cout<<"\n\t e-mail address:"<<disp->mail; cout<<"\n\t phone number:"<<disp->phone; getch(); } } void main() { int choice; address addressobj; while(1) { clrscr(); gotoxy(25,20); cout<<"ADDRESS BOOK \n\n\n\n"; cout<<"\n\t\t 1.ADD NEW ENTRY"; cout<<"\n\t\t 2.DELETE ENTRY"; cout<<"\n\t\t 3.MODIFY RECORD"; cout<<"\n\t\t 4.DISPLAY RECORD"; cout<<"\n\t\t 5.EXIT\n"; cout<<"\n\t\t Enter your choice [1-5]:"; cin>>choice; fflush(stdin); switch(choice) { case 1: addressobj.addrecord(); break; case 2: addressobj.deleterecord(); break; case 3: addressobj.modifyrecord(); break; case 4: addressobj.displayrecord(); break; case 5: return; } } }![]()
thanks in advance
Nb
[code][/code]tagged by Salem



LinkBack URL
About LinkBacks



