Thread: problem compiling ...

  1. #1
    Registered User
    Join Date
    Jul 2006
    Posts
    13

    problem compiling ...

    Hey everyone,

    I'm applying for a job .. I submitted a puzzle that works very well, but got an email back saying that they couldn't compile it. i am using mingw / msys to compile and run my program, and it works fine on my computer.

    is there another compiler that i could use to find these "errors" that they are getting on their end??

    “The code I recieved is segfaulting here:
    fflush(stdout);
    ---> greenHouse[numOfHouses]=lowest;
    numOfHouses++;
    }//while
    alternately, if anyone could take a look at my program and tell me if they also get errors, i'd really appreciate any help on this matter, as it's kinda frustrating me that i have a solution that works but can't submit it.

    thanks everyone,

    -Sean
    Last edited by 182blink; 09-08-2006 at 11:43 AM.

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    If they're saying that it's segfaulting then it's not actually a compile problem at all. Segfaults are runtime errors.

    Are you sure you're not just overrunning your greenHouse array bounds? That can lead to a "it works fine most of the time, but not always" problem.
    If you understand what you're doing, you're not learning anything.

  3. #3
    Registered User
    Join Date
    Jul 2006
    Posts
    13
    i don't know ... my program is static, there is no user input, so it should be the same every time. basically it reads in a file and outputs some text based on that file. even if the file changes, the variable numOfHouses should be fine ... unless they are doing really screwed up test cases. hmmm maybe i'll ask them about that.

    Just to confirm ... do segfaults give any information as to the type of error?? or just basically "runtime errors"? and what is a good debugging program for programming in c?

    Thanks,

    -Sean

  4. #4
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    do segfaults give any information as to the type of error
    segfaults are a specific type of error. It occurs when the program tries to access memory it doesn't have permission to, or tries to write to memory that is read-only.
    i don't know
    Well if you don't know then I would say that's a design flaw in your program. As a programmer, you should make sure you're not trampling over parts of memory that you shouldn't.
    Last edited by itsme86; 09-08-2006 at 11:10 AM.
    If you understand what you're doing, you're not learning anything.

  5. #5
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    It may be static in that there is no user input but is it the same file on there computers as the one you've been testing you're code on?

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,662
    > greenHouse
    Well if you did something like
    int *greenHouse;

    without bothering to allocate it, then sure it might work for you and give problems for someone else.

    Or maybe you forgot to account for the size when you allocated
    greenHouse = malloc ( 10 );
    is NOT space for 10 integers. Again, you might run off the end happily, but someone else might not.

    Or you could have done it right, and still incremented numOfHouses past whatever limit you asked for.

    Anything else, post your code.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem Running Program After Compiling
    By kristentx in forum C++ Programming
    Replies: 13
    Last Post: 09-12-2007, 10:46 AM
  2. Problem compiling simple code examples
    By Wintersun in forum Windows Programming
    Replies: 8
    Last Post: 08-14-2007, 10:30 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  4. compiling problem
    By tinkerbell20 in forum C++ Programming
    Replies: 6
    Last Post: 06-21-2005, 12:12 PM
  5. simple compiling problem
    By waxydock in forum C++ Programming
    Replies: 2
    Last Post: 03-26-2005, 10:33 AM