No errors, but wont run...

This is a discussion on No errors, but wont run... within the C++ Programming forums, part of the General Programming Boards category; Hi everyone Im a real newbie to this, so i guess ive prob done soemthing stupid... My program has be ...

  1. #1
    C++ Learner :D
    Join Date
    Mar 2004
    Posts
    69

    No errors, but wont run...

    Hi everyone

    Im a real newbie to this, so i guess ive prob done soemthing stupid...

    My program has be working fine, and i was testing that various parts of it worked, and it was goingn ok. I had to restart the compiler/editor (borland c++ 3) and now when i try to tun the program it starts then quits instantly!

    If i switch to the output screen it says "Abnormal Program Termination".

    Its been working fine for ages, any ideas what could be wrong?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    C++ Learner :D
    Join Date
    Mar 2004
    Posts
    69
    its 1000 lines long....

    isnt that a bit much to post

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    Yes, that's a bit much
    But what's a newbie doing with a 1000 line program?

    First thing, does it run outside the IDE? It may simply be running out of memory.

    Are you for example assuming that malloc() always succeeds?
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    C++ Learner :D
    Join Date
    Mar 2004
    Posts
    69
    Originally posted by Salem
    Yes, that's a bit much
    But what's a newbie doing with a 1000 line program?

    First thing, does it run outside the IDE? It may simply be running out of memory.

    Are you for example assuming that malloc() always succeeds?
    Ive been programming for 4 months now but i still think im a newbie... Its my major coursework piece for college so thats why tis longish.

    Nope, it wont work outside the IDE.

    whatis malloc()? ive never used it before.

  6. #6
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293
    malloc() allocates memory based on the size given.

    Eg --

    char *t = malloc(sizeof(char)*5);

    t would have enough space for 5 chars...I think

    Have you got a debugger? Perhaps you should get one if you don't!

  7. #7
    C++ Learner :D
    Join Date
    Mar 2004
    Posts
    69
    I use Borland Turbo C++ 3.0 (Old DOS based program).

    It has everything in one, a debugger, compiler and editor all in one.

    no errors are reported at all....

  8. #8
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    Well if you're going to post that much code, then I suggest

    1. Make sure you've indented the code properly. See the samples in the FAQ for some typical examples of well indented code.

    2. Use the "Attach file" at the bottom of the reply page to attach a copy of your source.

    3. Don't expect quick miracles for such large amounts of code.

    4. Get a better compiler. The standard of C++ which Turbo C++ 3.0 uses is quite far removed from what is current practice.
    Try www.compilers.net and find Dev-C++
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  9. #9
    Me -=SoKrA=-'s Avatar
    Join Date
    Oct 2002
    Location
    Europe
    Posts
    448
    Are you sure you're not doing a return 1 somewhere in main(), which would make the debugger think it's not ended right?
    Also, if the compiler gives you warnings, try to fix them, because they may have become fatal.
    Just some suggestions, not sure what could cause a program to act that weird.
    SoKrA-BTS "Judge not the program I made, but the one I've yet to code"
    I say what I say, I mean what I mean.
    IDE: emacs + make + gcc and proud of it.

  10. #10
    C++ Learner :D
    Join Date
    Mar 2004
    Posts
    69
    ive been looking at an older version of my code that i had saved an comparing the differences, i seem to have managed to fix it.

    Thank you, for trying to help me, sorry if i have wasted your time.


    BTW i have to use Turbo C++ 3.0, my teacher says i have to...

  11. #11
    C++ Learner :D
    Join Date
    Mar 2004
    Posts
    69
    ok, sorry about this, ive jsut stumbled on the exact casue of the problem.

    It appears when i insert this line:

    Code:
    float price;
    into this struct:

    Code:
    struct car  
    {
    char company_name[30];
    char regAB[3];
    char reg01[3];
    char regXYZ[4];
    long int mileage;
    char type_of_tyre[10];
    int no_of_tyres;
    int dd;
    int mm;
    int yyyy;
    float price;//this is the one that makes it go wrong, it runs without it 
    char comment[50];
    
    };


    any ideas why this could be?

  12. #12
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    Old DOS compilers have always been a bit funny about detecting when floating point support is required or not.

    If you just have a declaration and something like scanf(), then it usually gets it wrong, and reports some "floating point not linked" message.

    The hacky fix seems to be to declare a dumm global variable like
    Code:
    double fix_my_broken_compiler = 1.0;
    > BTW i have to use Turbo C++ 3.0, my teacher says i have to
    Yeah, and what does that tell you about the quality of the teacher?
    Don't tell me, they use void main() as well.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  13. #13
    C++ Learner :D
    Join Date
    Mar 2004
    Posts
    69
    ok, ill try that thanks...

    btw i use cout<<, not scanf()

    and yeah we used void main() (whats wrong with that)

  14. #14
    C++ Learner :D
    Join Date
    Mar 2004
    Posts
    69
    nope that variable didnt fix it...

  15. #15
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    > and yeah we used void main() (whats wrong with that)
    See the FAQ

    > nope that variable didnt fix it...
    I think you're going to have to attach the whole file then.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Segmentations and casting errors
    By Joke in forum C Programming
    Replies: 3
    Last Post: 07-14-2008, 04:52 PM
  2. executing errors
    By s0ul2squeeze in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2002, 12:43 PM
  3. errors in class(urgent )
    By ayesha in forum C++ Programming
    Replies: 1
    Last Post: 11-10-2001, 09:14 PM
  4. errors in class(urgent)
    By ayesha in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2001, 05:51 PM

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