scanf 读取字符串

时间:2025-04-28 18:00:33

#include <>
int main(void)
{
	freopen("", "r", stdin);
	char str[10], str2[10];
	scanf("%s", str);
	scanf("%s", str2);
	printf("%s: %s\n", str, str2);
	return 0;
}

$ cat  
U	 ASXSDX


       %s  Matches  a  sequence  of  non-white-space  characters;  the next
              pointer must be a pointer to the initial element of a  character
              array  that  is  long  enough to hold the input sequence and the
              terminating null byte ('\0'), which is added automatically.  The
              input string stops at white space or at the maximum field width,
              whichever occurs first.