以下是引用fragileeye在2011-6-6 00:07:20的发言:
#include <stdio.h>
int main(int argc, char *argv[])
{
int tool, ct;
char name[20];
scanf("%d\n%[^\n]%d", &tool, name, &ct);
printf("tool = %d\n",tool);
printf("name = %s\n", name);
printf("ct = %d\n", ct);
return 0;
}
/*input:(如果用scanf就得每次输入回车,建议用fgets())
1
Tom Curious
5
*/
/*output:
tool = 1
name = Tom Curious
ct = 5
*/
能否给无回车的版本,我找了fgets()的例子,也没研究出来