- 论坛徽章:
- 0
|
- #include <stdio.h>
- #include <string.h>
- #define FORMAT "%d\n%s\n%d"
- int main(int argc, char *argv[])
- {
- struct wodetian
- {
- int num;
- char name[20];
- int assignment;
- };
- struct wodetian sina;
- char *text = sina.name;
- fputs("Please enter the name of the students: ", stdout);
- fflush(stdout);
- if(fgets(text, sizeof text, stdin)!=NULL)
- {
- char * newline = strchr(text, '\n');
- if (newline!=0)
- {
- *newline = '\0';
- }
- sina.num=0;
- sina.assignment=100;
- printf(FORMAT, sina.num, text, sina.assignment);
- }
- return 0;
- }
复制代码
为何,我无论输入多少个,都是只显示3个字符? |
|