Code leapt over

This is a discussion on Code leapt over within the C Programming forums, part of the General Programming Boards category; The problem is that the program seems to leap over the central part of the code when executed, so it ...

  1. #1
    Registered User
    Join Date
    Jun 2002

    Exclamation Code leapt over

    The problem is that the program seems to leap over the central part of the code when executed, so it goes directly from the while loop to the system pause as indicated, ignoring all the ifs...

    Some help...

    #include <stdio.h>
    #define NMAX 100
      float datos[NMAX],max,min;
      int nelementos=0,i=0;
      printf("Introducir datos (0 para finalizar)\n");
      printf("dato[%d]: ",i);
        printf("dato[%d]: ",i);
    //this part isnt executed apparently...  
        printf("Valor maximo: %g,valor minimo: %g",max,min);
      else printf("no hay datos\n");
    //and program continues here 
      return 0;
    ---Programming is like roaming, you never know where you'll end at------

    If 'here' is pronounced as 'hear', why 'there' isnt pronounced as 'dear'??

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    That part isn't executed when you enter EOF. If you change your number to say 5, and actually enter all five, it works fine.

    printf("datos[0]: " ); scanf( "%f",&datos[0] );
    printf("datos[1]: " ); scanf( "%f",&datos[1] );
    printf("datos[2]: " ); scanf( "%f",&datos[2] );
    printf("datos[3]: " ); scanf( "%f",&datos[3] );
    printf("datos[4]: " ); scanf( "%f",&datos[4] );

    Replace your first loop with that. Then, once you've entered two of them, enter EOF, and watch your program do the exact same thing as with your loop.

    EOF kills your program.

    Last edited by quzah; 07-02-2002 at 08:13 PM.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extended ASCII Characters in an RTF Control
    By JustMax in forum C Programming
    Replies: 18
    Last Post: 04-03-2009, 09:20 PM
  2. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 08:34 AM
  3. Values changing without reason?
    By subtled in forum C Programming
    Replies: 2
    Last Post: 04-19-2007, 11:20 AM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 06:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 06:05 PM

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