Chris wrote: > > what am i doing wrong here. it compiles and works but after you enter in > the first value it just stops. > Take a look at the typical "if" statement that you are using if ( ( j = read_x1( x1 ) ) == 'E' ); <-- get rid of these semicolons** return EXIT_FAILURE; I think you'll want to get that semicolon that you have placed at the end of each if statement out of there. What is happening is that program execution control goes to "read_x1".The user enters a value, the function returns, and the condition of the if clause becomes false. The "if" statement then ends (at the semicolon), and program control jumps to the next line which say's "return EXIT_FAILURE;" which the program then executes ,and then ends. Program control never sees the next "if" statement. An easier way to accomplish the above input might be to pass an array to the input function. See the attatched example. /John <[EMAIL PROTECTED]> -- email: [EMAIL PROTECTED] Local mailserver <landreau.ruffe.edu> , remote <ns.computer.net> Real Programmers code in Ada!!
/* ex1.c */ #include <stdio.h> #include <stdlib.h> void read_vals1(float *); int main() { float x[4]; /* print_user_instructions(); */ read_vals1(x); printf("%f, %f, %f, %f \n", x[0], x[1], x[2], x[3]); exit(EXIT_SUCCESS); } void read_vals1(float a[]) { printf("Enter x1 x2 y1 y2 : "); if (scanf("%f %f %f %f", &a[0], &a[1], &a[2], &a[3]) != 4) { fprintf(stderr, "Input error\n"); exit(EXIT_FAILURE); } }