hi i don't know why but this code produces no output. I'm a beginner i don't get. why doesn't this work?
Code:#include <stdio.h> int main() { char c[] = "0110"; if (c == "0110") printf("%s", c); return 0; }
hi i don't know why but this code produces no output. I'm a beginner i don't get. why doesn't this work?
Code:#include <stdio.h> int main() { char c[] = "0110"; if (c == "0110") printf("%s", c); return 0; }
Or for the exact answer to your question, putting a string into char c [] puts it in read only format, so you can't output a value that is read only, it also has to be able to write the value (so initialize the size of the char array), see: string - What is the difference between char s[] and char *s in C? - Stack Overflow
Last edited by Terrance; 04-17-2017 at 04:23 AM.
Use strcmp for comparing strings.
"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson