Hey guys i have two problems in my c code. I have created a structure named rotor:
typedef struct rotor {
char characters[26];
int rotationPos;
} rotor;
I want to create an instance of that struct like this:
rotor r;
[error] r.characters[26]= {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y',
'Z'};
r.rotationPos = 5;
and it gives me the following error: "-Syntax erro; -Expected expression before '{'"
i also have this function
void rotate(rotor r) {
char aux[26];
int i;
for (i = 0; i < 26; i++) {
if (i == 0) {
[error] aux[26] = r->characters[i];
} else
[error] aux[i] = r->characters[i + 1];
}
[error] r->characters=aux;
}
that gives: "invalid type argument of '->' (have 'rotor')" Can you guys tell me what am i doing wrong please? Thanks!