Thread: Strange things in my code

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    147

    Strange things in my code

    I have a crash (program unexpectly exited) in my code. Trying to debug it with printf, I come to the line:

    Code:
            int tiempo_seguridad[12] = { 0, 25, 100, 100, 200, 200, 200, 300, 300, 300, 300, 300};
    where it looks it is the problem.

    If I put:

    Code:
            int tiempo_seguridad[12] = { 0, 25, 100, 100, 200, 200, 200, 300, 300, 300, 300, 300};
    printf("Aqui\n");
    the program crash and I dont see the printf

    But if i write

    Code:
            printf("Aqui\n");
            int tiempo_seguridad[12] = { 0, 25, 100, 100, 200, 200, 200, 300, 300, 300, 300, 300};
    the program does not crash never!

    how can I see where is my problem. I dont see any problem in that line.

    thanks.
    Last edited by Kempelen; 11-06-2016 at 05:30 AM.

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    In general, debuggers do a better job. You can debug with printf to an extent, but I find it's a relatively small set of logic errors that really make the technique helpful in any way. There are problems that you can't fix with printf - such as if the program ever hanged or simply crashed. I bet you'd figure out your error if you learn how to use them.


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bugs (and strange things...)
    By kermi3 in forum General Discussions
    Replies: 385
    Last Post: 12-02-2018, 07:24 AM
  2. Strange things happening with counter
    By cnewbie1 in forum C Programming
    Replies: 4
    Last Post: 05-31-2011, 08:48 AM
  3. weird things going on in my code
    By -EquinoX- in forum C Programming
    Replies: 6
    Last Post: 11-16-2008, 04:44 AM
  4. Strange things (double increment needed????)
    By dezz101 in forum C Programming
    Replies: 4
    Last Post: 10-30-2008, 08:07 AM
  5. some strange code. please help!
    By Antigloss in forum C Programming
    Replies: 5
    Last Post: 08-16-2005, 10:59 AM

Tags for this Thread