I have a problem which I can not solve.
If this query is answered as “yes”, then should anrede = female.
Dev++ gives me this error:
ISO C++ forbids assignment of arrays
char anrede[10];
printf("Anrede: female?? Yes/No");
scanf("%s", &anrede);
if(anrede == "Yes"){
anrede = "female";
} else{
anrede = "male";
}
Can someone help me?
Given that your example is actually in C, trojanfoe’s excellent answer might not suit you so well, in which case what you want is strcpy() and strcmp():
But you really don’t want to be doing that if you can avoid it. strcpy() has no idea of buffer sizes, so it’ll merrily run over the end of your target array and either corrupt your program’s data or immediately crash. strncpy() is a nice alternative with a maximum length parameter, but it’s not always available.
I’d go with the standard C++ solution trojanfoe posted, unless you actually do need to be writing in C (in which case, the question’s incorrectly tagged).