我正在做一个程序,询问用户姓名和 ID 号......然后我添加了一个搜索功能,例如搜索名称“bob”它说“Bob 在数组位置 x 中找到,ID:xxxxx”
我的问题是代码的“ID:xxxx”部分给了我随机数......它应该是例如1234,但它给了我像4210832这样的东西
这是代码
void search_surname()
{
    int index, found=0;
    char surname_to_find[10];
    printf("Please enter the student surname to search for\n\n");
    gets(surname_to_find);
    fflush(stdin);
    system("cls");
    for(index=0;index<height_of_array;index++)
    {
        if(strcmpi(surname_to_find, surname[index]) == 0)
        {
            found=1;
            system("cls");                                                      
            printf("%s found in array position %i, with the ID: %i \n\n", surname_to_find,     
            index+1, id[array_index] );
            getch();
我不是 100% 确定为什么它给我随机数
谢谢。