I am writing a C program for my exam and i am facing some issues. For example, in an this exercise :
char y = 'a';
if (y >= 65)
printf("MAJOR");
or :
char a[] = "bare";
if (a[0] >= 65)
printf("MAJOR");
I would really like to get MAJOR printed but I always get an error.
My aim is to see if an element of my char array is major or equals to a specified ASCII value (65 is 'A').
Also I got a pointer that actually needs to move in the char array: how can I scroll it trough until '\0' ?
I tried with :
for (i = 0 ; &p->info[i] != '\0' && &s[i] != '\0'; i++)
// the info field of this struct is type char *
Where info is char* and s is char s[].
Is this for loop fine?
EDIT: NEW ISSUE
Guys it's really weird i got a generic error trying to run just this line of code:
char y = 'a';
Seems that my 'y' variable is filled with an underscore instead of 'a'....? I'm using Xcode right now
Aucun commentaire:
Enregistrer un commentaire