All pastes #2077593 Raw Edit

Scanf Test

public c v1 · immutable
#2077593 ·published 2011-08-21 17:16 UTC
rendered paste body
#include<stdio.h>int main(){    char test1[60],test2[60];    int ret1,ret2;    printf("Enter the first string:\n");    ret1=scanf("%10s", test1);    printf("Enter the second string:\n");    ret2=scanf("%10s", test2);    printf("\n%s %s", test1, test2);    printf("\n%d %d\n", ret1, ret2); /*prints "1 1"*/    return 0;}/*This is an example program to explain my question about scanf function.  In this example, is user inputs more than 10 characters at the first call of  scanf, the second call will put the remaining characters to the second string  and return immediately, withou reading from stdin, and without returning any  kind of error code.  Is this behavior expected? What should I modify in this program in order to  scanf to throw away the remaining characters and read again from stdin?*/