Mega Code Archive

 
Categories / C Tutorial / Data Type
 

Reading characters and strings

#include <stdio.h> int main() {     char x;          char y[ 9 ];         printf( "Enter a string: " );    scanf( "%c%s", &x, y );    printf( "The input was:\n" );    printf( "the character \"%c\" ", x );    printf( "and the string \"%s\"\n", y );    return 0;  } Enter a string: string The input was: the character "s" and the string "tring"