Thread: Segmentation Fault

  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    38

    Segmentation Fault

    Hi,
    In this following section of my code I'm getting a segmentation fault:

    Code:
    /* Displays a summary of all books in the system. */
    void displayBooks(BookListType* booklist)
    {
        BookType* curr;
       curr = booklist->head;
       printf("%s %2s %32s %11s %5s %7s\n","ID","Title","Author","Year","Price","Co$
       printf("-- ------------------------------- ------------- ---- ------- -----\$
       while(curr != NULL)
       {
          printf("%2d %-31s %-13s %-2d%2c%06.2f %5d\n",curr->id,curr->title,curr->a$
          curr = curr->next;
       }
    
    }
    When I run my program on Ubuntu I'm not getting any errors. Would anyone know what could be causing this?

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    My guess is that 'booklist' is NULL. Also, whatever you're copying from seems to be truncating your lines with dollar signs.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. segmentation fault... first time with unix...
    By theMethod in forum C Programming
    Replies: 16
    Last Post: 09-30-2008, 02:01 AM
  2. Segmentation fault
    By bennyandthejets in forum C++ Programming
    Replies: 7
    Last Post: 09-07-2005, 05:04 PM
  3. Segmentation fault
    By NoUse in forum C Programming
    Replies: 4
    Last Post: 03-26-2005, 03:29 PM
  4. Locating A Segmentation Fault
    By Stack Overflow in forum C Programming
    Replies: 12
    Last Post: 12-14-2004, 01:33 PM
  5. Segmentation fault...
    By alvifarooq in forum C++ Programming
    Replies: 14
    Last Post: 09-26-2004, 12:53 PM