Thread: LinkedList Problem

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    1

    LinkedList Problem

    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 ^_^

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    If you are too lazy to post code, be aware most people are also too lazy to download it.

    << !! Posting Code? Read this First !! >>
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Ultraviolence Connoisseur
    Join Date
    Mar 2004
    Posts
    555
    The appropriate function OP is talking about from his attached source:
    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);
        }
    }
    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.
    Last edited by nonpuz; 03-01-2010 at 08:39 PM. Reason: pulled more code out of sourcefile

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  2. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  3. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  4. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  5. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM