#Cannot convert from bool to const char*
13 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
const char *foo(bool b) {
return b ? "true" : "false";
}
im already using something similar, but doesnt work
did you #include <string.h>?
;compile
#include <string.h>
#include <stdbool.h>
#include <stdio.h>
int main() {
char cs[20];
bool b = true;
strcpy(cs, b ? "1" : "0");
printf("%s\n", cs);
}
Program Output
1
elmonkeking | 78ms | c | x86-64 gcc 13.2 | godbolt.org
As you can see it works perfectly fine
Probably just what nullstrawberry said: You forgot to include string.h
it recognises the function
nvm I didnt something in code it works now
!solved