i have been trying to figure out the problem
i cant enter a name at the createProfile function...
anyone can give me advice ??
really appreciate it ^_^
Printable View
i have been trying to figure out the problem
i cant enter a name at the createProfile function...
anyone can give me advice ??
really appreciate it ^_^
If you are too lazy to post code, be aware most people are also too lazy to download it.
http://cboard.cprogramming.com/c-pro...ead-first.html
The appropriate function OP is talking about from his attached source:
I think what you're asking is you can't input a name? ...other then the fact that you are using GETS which is very very bad idea, as long as the user gives you 40 characters or less I don't see why it wouldn't work.Code:void createPro(LinkedList *Profile)
{
LinkedList temp,curr;
char fName[41];
char fAddress[41];
int flag=0,iAge,iScrtNo;
clrscr();
gotoxy(5,7);
printf("Name:");
gets(fName);
gotoxy(5,8);
printf("Address: ");
gets(fAddress);
gotoxy(5,9);
printf("Age: ");
scanf("%d",&iAge);
gotoxy(5,10);
printf("Secret Number: ");
scanf("%d",&iScrtNo);
curr=*Profile;
if(curr==NULL)
{
temp=malloc(sizeof(LinkedList));
strcpy(temp->name,fName);
strcpy(temp->address,fAddress);
temp->age=iAge;
temp->scrtNo=iScrtNo;
temp->next=NULL;
*Profile=temp;
flag=1;
}
else
{
while(curr->next!=NULL)
{
curr=curr->next;
}
temp=malloc(sizeof(LinkedList));
strcpy(temp->name,fName);
strcpy(temp->address,fAddress);
temp->age=iAge;
temp->scrtNo=iScrtNo;
temp->next=NULL;
curr->next=temp;
flag=1;
}
if(flag==1)
{
clrscr();
printf("Profile Added");
}
else
{
exit(0);
}
}