Thread: No errors, but wont run...

  1. #16
    C++ Learner :D
    Join Date
    Mar 2004
    ok, thanks for your help, ive fixed it now

    I had declared it like this:

    car car_details[300];
    but when i reduced it to:

    car car_details[285];
    it worked.

  2. #17
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003
    Thats one of those stange bugs that indicates a buffer overflow or uninitialized variables somewhere. I've once achieved something similar to this by using

    for (i; i<10; i++) {
      get some memory here
    without ever initalizing i. The bugs you get afterwards are strange and change when changing the program, sometimes they seem fixed but then they pop up again. Until you find the real cause.

    Salem might remember this.

    your code here....


  3. #18
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > car car_details[285];
    Each car is just over 100 bytes
    printf( "sizeof car = %lu\n", (unsigned long)sizeof(car) );

    All cars are going to be 100*285, which is about 29K bytes.
    printf( "sizeof all cars = %lu\n", (unsigned long)sizeof(car_details) );

    My guess is, that adding all your other global variables takes this up to the max allowed by 16 bit compilers of 64K of data.

    The way you get round this is by
    1. choosing the large model (not small)
    2. putting global variables in different source files (then you get a max of 64K per variable), not 64K in total.

    I repeat my earlier comment - GET A DECENT COMPILER!.
    Modern 32 bit compilers have the same limit, but its like 2GB, not 64KB
    There is no possible justification for continuing to use that old fossil.

    > float price;//this is the one that makes it go wrong, it runs without it
    Only because it saved you a K or so of data space.
    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. 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, 01:43 PM
  3. errors in class(urgent )
    By ayesha in forum C++ Programming
    Replies: 1
    Last Post: 11-10-2001, 10:14 PM
  4. errors in class(urgent)
    By ayesha in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2001, 06:51 PM