Home > Back-end >  The letters of an input to output in reverse chronological order
The letters of an input to output in reverse chronological order

Time:09-17

, help to look at me this program error in there? Running shows that the scanf that line is wrong, but and online is so in the book? Can't use scanf_s?

# include & lt; stdio.h>
# include
Int main (void)
{
Int I, j, n.
Char name [26].//define an array
Printf (" Pls enter your name: \ n ");
Scanf_s (" % s ", name);//the input words in array
N=strlen (name);//use strlen digit of the input word is assigned to the n
For (I=0, j=n; I & lt; n; I++)
Printf (" % c ", the name [- j]);
system("pause");
return 0;


}

CodePudding user response:

 scanf_s (" % s ", name, 26).//the input words stored in an array of 

For your reference ~

Scanf_s for % s need to the length of the input buffer, on the one hand, it is safer than the scanf scanf_s

CodePudding user response:

Learning, not the same
  • Related