【发布时间】:2016-06-11 00:09:16
【问题描述】:
这是我想在 C 中运行的代码。
#include<stdio.h>
#include<string.h>
main()
{
struct record {
char name[2];
char letter;
};
struct record student[10];
strcpy(student[0].name,"t");//copy "t" to first struct's name variable
strcpy(student[1].name,"ri");//copy "ri" to second struct's name variable
student[0].letter='a';//copy "a" to first struct's letter variable
student[1].letter='b';//copy "b" to second struct's letter variable
printf("%s %s %c %c", student[0].name, student[1].name, student[0].letter, student[1].letter);
}
我期望的输出是:t ri a b
但是我得到:t rib a b
我做错了什么?
【问题讨论】: