There are two methods of input string spaces

String input spaces There are two methods
1, gets function using
Eg of:
char S [100];
gets (S);

2, using the scanf% [] format control characters
Eg:! Love you input the I
#include " the stdio .h "
void main ()
{
char STR [50];
Scanf ("% [^ \ n-] ", STR); / * Scanf ("% S ", STR); not receiving spaces * /
the printf ("% S \ n-", STR);
}
input: I □ love □ you (□ ↘ space representatives, represent a carriage ↘)!
output: the I Love you!
Scanf herein ("% [^ \ n] ", str); a string representation of the input end with a carriage return.

Guess you like

Origin www.cnblogs.com/Theo-sblogs/p/11234821.html