Thread: Question

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    10

    Question

    What am I doing wrong with this linked list? Cause I'm getting an error of my type and an error that delname is not declared.

    void erase()
    {
    struct Customer *ptrthis;
    struct Customer *ptrlast;
    char delname[81];

    if (ptrfirst == NULL)
    { printf("\nEmpty list.\n"); return; }
    printf("\nEnter name to be deleted: ");
    gets(delname);
    ptrthis = ptrfirst;
    do
    {
    if( strcmp(ptrthis->Cname, delname)==0 )
    {
    if(ptrthis==ptrfirst)
    ptrfirst = ptrthis->ptrnext;
    else
    ptrlast->ptrnext = ptrthis->ptrnext;

    free(ptrthis);
    return;
    }
    ptrlast = ptrthis;
    ptrthis = ptrthis->ptrnext;
    }
    while(ptrthis != NULL);
    printf("No such name on list\n");
    }

  2. #2
    Unregistered
    Guest
    Have you declared ptrnext?

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    10
    Yep, it's delcared. This is what it looks like in my structure

    struct Customer *ptrnext;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM