Write a program that requests your first name and does the following with it:
Prints it in a field three characters wider than the name.
But I don't know how long is scanf input ( name ). If I use strlen() function like this int x = strlen ( name ) I can't just write printf ( "%d%s",x, name). Can this exercise be solved?Code:#include <stdio.h> #include <string.h> int main ( void ) { char name[20]; scanf ( "%s", name ); printf ( "%s", name );//If my name is 5 characters long field must be 8 //printf ( "%8s", name ); return 0; }



LinkBack URL
About LinkBacks



