previous | start | next

Examples: scanf

int n;
int x;
float y;
double z;

printf("Enter 3 values: an integer, a float, and a double: ");
n = scanf("%d %f %lf", &x, &y, &z);

The value returned will be 0, 1, 2, or 3 depending on how many successful conversions occurred.

The input conversions are attempted in order. If some conversion fails ( e.g. letters are input when a number is expected), scanf returns without trying the remaining conversions.



previous | start | next