c问题(看看哪儿有问题)

来源:百度知道 编辑:UC知道 时间:2024/06/21 19:46:41
/*输入学生的记录并输出*/
#include "stdio.h"
#include "conio.h"
/* 学生人数*/
#define CNT 2

struct student /*定义结构体*/
{
char sno[8];
char sname[18];
int sgrade;
};

void input(struct student *ps); /*函数声明*/

main()
{
int i;
struct student st1[CNT];
input(st1); /*函数调用*/

printf("The input of you is:\nsno sname sgrade \n\n");/*输出记录*/
for(i=0;i<CNT;i++)
printf("%s%s%d\n",st1[i].sno,st1[i].sname,st1[i].sgrade);

getch();
}

void input(struct student *ps) /*输入记录函数 */
{
int i;
printf("Please input the student's information:\nexample:0602001, lucy , 65 \n");
printf("\nsno , sname , sgrade \n");
for(i=0;i<CNT;

错误不多,简单注释一下吧:
/*输入学生的记录并输出*/
#include "stdio.h"
#include "conio.h"
/* 学生人数*/
#define CNT 2

struct student /*定义结构体*/
{
char sno[8];
char sname[18];
int sgrade;
};

void input(struct student *ps); /*函数声明*/

void main()
{
int i;
struct student st1[CNT];
input(st1); /*函数调用*/

printf("The input of you is:\nsno sname sgrade \n\n");/*输出记录*/
for(i=0;i<CNT;i++)
printf("%s %s %d\n",st1[i].sno,st1[i].sname,st1[i].sgrade); //这里,注意输出格式加空格

getch();
}

void input(struct student *ps) /*输入记录函数 */
{
int i;
printf("Please input the student's information:\nexample:0602001, lucy , 65 \n");
printf("\nsno , sname , sgrade \n");
for(i=0;i<CNT;i++)
{
scanf("%s%s%d",(ps+i)-