在结构体数组里初始化字符串出现警告
#include<stdio.h>
#include<string.h>
typedef struct
{
int number;
char name[10]="smith";
char gender[5];
int age;
} Student;
#include<string.h>
typedef struct
{
int number;
char name[10]="smith";
char gender[5];
int age;
} Student;
不要在结构定义的时候初始化。这个功能支持需要C++11,或者GNU++11,你看看你的编译器是否支持吧
一般这么写
typedef struct
{
int number;
char name[10];
char gender[5];
int age;
} Student;
Student s;
strcpy(s.name,"smith");