strcmp读取错误怎么办啊


#define _CRT_NONSTDC_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE
#include<assert.h>
#include<stdio.h>
#include <string>
using namespace std;
#define size 50
int main() {
    struct student {
        int nume_student;
        char name_student[20];
        char sex_student;
        int phone_number;
        float score_yuwen;
        float score_math;
        float score_english;
        float score_pinde;
        float total_score;
        int rank;
        char attach[50];
    }stu[size];
    struct num {
        char iuy[100];
        char tyu[100];
    }nty[size];
    char uio[100];
    long long int a;
    char b;
    char c;
    long long int d;
    float e;
    float f;
    float g;
    float h;
    float j;
    int k;
    char* l;
    int i;
    int lo;
    long long int op;
    printf("请问您要输入多少个信息?");
    scanf("%d", &lo);
    printf("确认输入%d个信息\n开始输入您的信息", lo);
    for (i = 0;i<lo;i++)
    {
        scanf("%d %s %c %d %f %f %f %f %s",&a, stu[i].name_student, &c,&d, &e, &f, &g, &h,stu[i].attach);
        stu[i].sex_student = c;
        stu[i].score_yuwen = e;
        stu[i].score_math = f;
        stu[i].score_english = g;
        stu[i].score_pinde = h;
        stu[i].total_score = e + f + g + h;
        sprintf(nty[i].iuy, "%lld", a);
        sprintf(nty[i].tyu, "%lld", d);


    }
    printf("请问您要查询哪个学号?\n");
    scanf("%lld", &op);
    sprintf(uio, "%lld", op);
    i = 0;
    int r = strcmp(uio, nty[i].iuy);   **//在这个下面三行加过assert判断nty[i].iuy和r和uio是否为0,都不为0。下面还是出错**
    while (r!=0)
    {
        i++;
        r = strcmp(uio, nty[i].iuy);
    }
    printf("学号为%s 姓名为%s 性别为%c 手机号为%s 语文成绩为%f 数学成绩为%f 英语成绩为%f 品德分为%f 综合评测分为%f 排名为 备注为%s", nty[i].iuy,stu[i].name_student,stu[i].sex_student, nty[i].tyu, stu[i].score_yuwen, stu[i].score_math, stu[i].score_english, stu[i].score_pinde, stu[i].total_score, stu[i].attach);
}

img

我根据你的代码,去除了第63行的那两个星号,然后第6行导入头文件那里改为 #include <string.h>,然后运行程序,程序正常执行。
修改如下:

#define _CRT_NONSTDC_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE
#include<assert.h>
#include<stdio.h>
#include <string.h>

using namespace std;
#define size 50
int main() {
    struct student {
        int nume_student;
        char name_student[20];
        char sex_student;
        int phone_number;
        float score_yuwen;
        float score_math;
        float score_english;
        float score_pinde;
        float total_score;
        int rank;
        char attach[50];
    }stu[size];
    struct num {
        char iuy[100];
        char tyu[100];
    }nty[size];
    char uio[100];
    long long int a;
    char b;
    char c;
    long long int d;
    float e;
    float f;
    float g;
    float h;
    float j;
    int k;
    char* l;
    int i;
    int lo;
    long long int op;
    printf("请问您要输入多少个信息?");
    scanf("%d", &lo);
    printf("确认输入%d个信息\n开始输入您的信息", lo);
    for (i = 0;i<lo;i++)
    {
        scanf("%d %s %c %d %f %f %f %f %s",&a, stu[i].name_student, &c,&d, &e, &f, &g, &h,stu[i].attach);
        stu[i].sex_student = c;
        stu[i].score_yuwen = e;
        stu[i].score_math = f;
        stu[i].score_english = g;
        stu[i].score_pinde = h;
        stu[i].total_score = e + f + g + h;
        sprintf(nty[i].iuy, "%lld", a);
        sprintf(nty[i].tyu, "%lld", d);
 
 
    }
    printf("请问您要查询哪个学号?\n");
    scanf("%lld", &op);
    sprintf(uio, "%lld", op);
    i = 0;
    int r = strcmp(uio, nty[i].iuy);   //在这个下面三行加过assert判断nty[i].iuy和r和uio是否为0,都不为0。下面还是出错**
    while (r!=0)
    {
        i++;
        r = strcmp(uio, nty[i].iuy);
    }
    printf("学号为%s 姓名为%s 性别为%c 手机号为%s 语文成绩为%f 数学成绩为%f 英语成绩为%f 品德分为%f 综合评测分为%f 排名为 备注为%s", nty[i].iuy,stu[i].name_student,stu[i].sex_student, nty[i].tyu, stu[i].score_yuwen, stu[i].score_math, stu[i].score_english, stu[i].score_pinde, stu[i].total_score, stu[i].attach);
}

img