Sono novizio nel mondo C e ho due domande probabilmente stupide.Problemi con le stringhe in C
Sto leggendo di strutture in C e qui è dove mi sono bloccato. Diciamo che abbiamo struttura come questa
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"
Come passare il testo in Ford.model in quel caso?
La mia seconda domanda riguarda anche le stringhe. Questo codice funziona bene
char model[50] = "Focus";
printf("Model is %s", model);
Ma questo non
char model[50];
model = "Focus";
Qualcuno può spiegare perché non funziona?
La tua domanda non ha assolutamente nulla a che fare con le strutture; è la stessa domanda sugli archi due volte. –