Thread: segmentation fault (core dumped)?

  1. #16
    Registered User
    Join Date
    Apr 2012
    Posts
    17
    Quote Originally Posted by oogabooga View Post
    Did you fix these lines yet?
    Code:
    // in add
    (*q) -> back -> next;
    // in fetch
    (*q) -> front -> next;
    If you changed your gcc invocation in your makefile by adding -Wall to CFLAGS like this
    Code:
    CFLAGS = -Wall -o a.out
    then the compiler would point out those lines automatically. It will also notify you that something is wrong with your fetch routine's return. Nifty.

    (And why would you call your output a.out in a makefile? Still, that's your business.)

    Presumably in add you want
    Code:
    (*q) -> back -> next = temp;
    I can't comprehend what fetch is attemting to do.

    EDIT: I took another peek at fetch and I get it now. But you presumably want to free(temp) and return fetch_data whether or not it's the last node being removed.
    you have been very helpful, thank you very much. I have fixed these things you have told me about and tried out that -Wall in my makefile, which is awesome btw, but I still have the same error. program will not run. one of the errors I finally got rid of that the -Wall command showed me was on line 71 (inside fetch) which i removed by changing
    Code:
    (*q) -> front -> next;
    to
    Code:
    (*q) -> front = (*q) -> front -> next;
    which I'm not really sure if that makes sense to an experienced programmer, but it seemed to work out in my head... and I also moved the free temp and return fetch data outside of the else statement, but that did not fix it either.
    Last edited by tkd_aj; 04-17-2012 at 11:41 PM.

  2. #17
    Registered User
    Join Date
    Apr 2012
    Posts
    17
    I also have two more error's that I didn't think were a big deal but after googling them I guess they might be?

    the two errors are both: "warning: control reaches end of non-void function [Wreturn-type]. it says one of these is at line 56 and one is at line 65 both in my queue.c.
    line 56 is the ending bracket for my main() and 65 is the ending bracket for my menu(). anyone know what is causing this or how to fix it?

  3. #18
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by tkd_aj
    the two errors are both: "warning: control reaches end of non-void function [Wreturn-type]. it says one of these is at line 56 and one is at line 65 both in my queue.c.
    line 56 is the ending bracket for my main() and 65 is the ending bracket for my menu(). anyone know what is causing this or how to fix it?
    Basically, you declared the function as returning something (i.e., the return type is not void), but there is a flow of control through that function such that you don't return anything.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Segmentation fault (core dumped)
    By jonagondo in forum C Programming
    Replies: 6
    Last Post: 01-04-2012, 03:56 PM
  2. Segmentation Fault (Core Dumped)
    By pureenergy13 in forum C Programming
    Replies: 3
    Last Post: 11-02-2011, 07:50 AM
  3. Segmentation fault (core dumped)????
    By yosipoa in forum C++ Programming
    Replies: 2
    Last Post: 07-20-2011, 01:18 PM
  4. Segmentation fault, core dumped
    By dweenigma in forum C Programming
    Replies: 2
    Last Post: 05-21-2007, 03:50 PM
  5. Segmentation fault (core dumped)
    By JYSN in forum C Programming
    Replies: 1
    Last Post: 02-21-2002, 03:24 AM

Tags for this Thread