current position:Home>Why can't I output with structure

Why can't I output with structure

2022-02-03 01:22:23 CSDN Q & A



Refer to the answer 1:

I'll follow your code , It's just for A parenthesis is added after the loop , It can run ! Changed a place ,scanf It's changed there ,
Input similar : xu 60 70 80 90, The code is as follows :

#include <stdio.h>#include <string.h>struct student{    char name[10];    int num;    int yu,shu,wai;    int sum;} e[3];int main(){    int i,j;        for(i=0;i<3;i++){        printf(" Enter the first %d Personal name , Student number , Extra linguistic achievement :",i);        scanf("%s %d %d %d %d",e[i].name,&e[i].num,&e[i].yu,&e[i].shu, &e[i].wai);    }        for(j=0;j<3;j++){        e[j].sum=e[j].yu+e[j].shu+e[j].wai;    }        for(i=0;i<3;i++){        printf("%s,%d,%d,%d,%d,%d\n",e[i].name,e[i].num,e[i].yu,e[i].shu,e[i].wai,e[i].sum);    }        return 0;}


Refer to the answer 2:

Refer to the answer 3:

Don't write Chinese punctuation in the code , Don't write Chinese punctuation when entering

Refer to the answer 4:

Refer to the answer 5:

Is it possible that scanf Medium The address of the name is wrong , In the original picture is &e[i].name[10]; Change it to &e[i].name[0] Is it feasible

Refer to the answer 6:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.

Random recommended