Syntax errors

My Console has to display state of Bool Status , if that is False it will display in Red Color(12) Off ,if that is True it will display in Green Color (10) On.
I am getting Syntax error in this ,idk how to fix or am I using right way to change color ?
1
2
3
4
5
6
7
8
9
void ChangeColor(unsigned short color)
{
	HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleTextAttribute(hcon, color);
}

int main(){
  printf("Status: %s\n", (Status ? ChangeColor(10); "On" : ChangeColor(12); "Off"));
}
I am getting Syntax error

Tell us the error
I'm guessing it is complaining about this line:
printf("Status: %s\n", (Status ? ChangeColor(10); "On" : ChangeColor(12); "Off"))

But you didn't tell us which line was line 428, so it's just a guess. You need to get better at asking questions. Making us try to guess what information you have is not helpful.

What if you rewrite main ?

1
2
3
4
5
6
7
8
9
10
11
12
int main()
{
    if (Status)
    { 
         ChangeColor(10);
         printf("On");
    else
    {
        ChangeColor(12); 
        printf("Off");
     }
}


Last edited on
Thanks and for bad question It seems like I dont use my brain . :(
Topic archived. No new replies allowed.