The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

stdin exploding? Help with c program please

verpaverpa Registered User regular
edited March 2007 in Help / Advice Forum
Ok so heres the problem:

verpa@ignare:~/Qproject$ ./Que<test
2
1 , 2
Segmentation fault (core dumped)

Yay seg fault.Well thats a bit weird so lets look at the code.

test = scanf(" %d , %u ", &name, &seconds);
printf("%d \n", test);
printf("%d , %u \n ", name, seconds);

Weird none of that should cause a seg fault whats next?

enqueue(name, seconds, queue);

Oh ok, well enqueue is a function that adds a node to a linked list it must be that but wait, the first line of enqueue?

printf("Queue");

Wait that lines not even being printed so the seg fault is happening before that? Ok....


Can any one help me with this?

542987-1.png
verpa on

Posts

  • ValkunValkun Registered User regular
    edited March 2007
    Try putting "Queue\n" for debugging purposes, C has a strange habit of not outputting text until it receives an EOL character.

    Without pasting your code it'll be pretty difficult to track down the problem. "Segmentation Fault" is a pretty generic error afterall. If you have access to it, try using Visual Studios. When a program crashes due to a segmentation fault you can use VS to "debug" it and the line which is causing the problem will be pointed out to you along with all the values currently stored in your various variables.

    Valkun on
  • ObsObs __BANNED USERS regular
    edited March 2007
    post the whole code.

    Obs on
  • SmasherSmasher Starting to get dizzy Registered User regular
    edited March 2007
    printf("Queue") is being written to the buffer and not flushed to the screen due to the seg fault. Add a \n to the end of it like with your other lines.

    Oops, Thrawn already said that. Not sure how I missed that.

    Smasher on
Sign In or Register to comment.