字符串我用C世界的新手,我有两个可能愚蠢的问题。麻烦在C
我读有关C结构和这里是我卡住了。假设我们有这样的结构
typedef structs {
char model[50];
int yearOfManufacture;
int price;
} Car;
Car Ford;
Ford.yearOfManufacture = 1997;
Ford.price = 3000;
//The line below gives me an error "Array type char[50] is not assignable
Ford.model = "Focus"
如何在这种情况下将文本传递到Ford.model?
我的第二个问题也是关于字符串。 此代码工作正常
char model[50] = "Focus";
printf("Model is %s", model);
但是这一次不
char model[50];
model = "Focus";
任何人都可以解释为什么它不工作?
你的问题有绝对无关,与结构;这是关于字符串两次的相同问题。 –