我写了这个程序
#include<stdio.h>
struct student
{
char name[22];
char rollno[10];
unsigned long long int phno;
};
int main()
{
int i,j;
char c[1];
struct student cse[10],*p;
p=cse;
for(i=0;i<3;i++)
{
printf("enter student name\n");
gets(cse[i].name);
printf("enter student roll number \n");
gets(cse[i].rollno);
printf("enter student phone number \n");
scanf("%llu",&cse[i].phno);
gets(c); //to catch the '\n' left unprocessed by scanf
}
for(i=0;i<3;i++);
printf("the following is the information about CSE B student\n");
printf("%-6s%-24s%-14s%-14s \n","S.no","student Name","Roll no","phone no.");
for(i=0;i<3;i++)
{
printf("%-6d%-24s%-20s%-14llu \n",i+1,(*p).name,(*p).rollno,(*p).phno);
++p;
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出是
the following is the information about CSE B student
S.no student Name Roll no phone no.
1 kapil 1234567890??I 1234567890
2 kumar 9876543210??L 9876543210
3 sharma 5123467890??a1 5123467980
Run Code Online (Sandbox Code Playgroud)
Roll no coloumns中有一些不需要的和不可理解的字符,这些无效字符的打印原因是什么
〜
| 归档时间: |
|
| 查看次数: |
495 次 |
| 最近记录: |