程序中打印无效字符

invalid character are printed in program

程序我写好了

#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;
}

输出是

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     

Roll no coloumns中有一些不需要的和无法理解的字符,打印这些无效字符的原因是什么

~

数组 rollno 仅可存储 10 个字符,但您输入了 10 个或更多字符。如果您的卷号是 10 位数字,则至少需要 11 个字符才能将其打印为字符串,一个额外的字符用于终止空字节。这在技术上是 undefined behaviour,使您的程序无效。

请注意,自 C11 以来,gets() 已被弃用,您实际上应该使用 fgets()