+ 1
Why this mini C code doesn't work?
6 Réponses
+ 2
I used pointer to assign the value, you can't assign directly any value to string
Here is the updated code
https://code.sololearn.com/cNTTy2QmHwEJ/?ref=app
+ 1
Thanks Tarun, i'vr tried with pointer, but not like that! 👍
+ 1
Because y is a array. Do a for loop. Another way is to go with the pointer in the char.
+ 1
Theo Martier
char* is better.
But if you want to work with char array, you could use strcpy
int main() {
char y[8];
int x = 4;
x >= 5 ? strcpy(y, "true") : strcpy(y,"false");
printf("%s", y);
return 0;
}
+ 1
Thanks Bob!
0
Thanks you Werg