[求助]字符串变量能直接赋值吗?
我有一段初学程序,是关于字符串变量问题:
#include<cstdio>
#include<cstring>
void main()
{
struct person{
char name[6];
int age;
char sex;
};
struct person a={"limin",23,'m'};
struct person b;
char c[6]="abcde";
b.name[6]=c[6]; b.age=29;
b.sex='f';
printf("%d \n",b.age);
if(b.sex=='m')
printf("%s is a man.\n",c[6]);
else
printf("%s is a woman.\n",b.name);
}
DEBUG时提示:warning C4700: local variable 'c' used without having been initialized//
为啥"abdce"没有赋给C[6]。