Like Tree2Likes

segmentation fault (core dumped)?

This is a discussion on segmentation fault (core dumped)? within the C Programming forums, part of the General Programming Boards category; Originally Posted by oogabooga Did you fix these lines yet? Code: // in add (*q) -> back -> next; // ...

  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
    21,644
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Page 2 of 2 FirstFirst 12
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, 02: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, 02:24 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21