extraneous `char' ignored problem

The following function compares the two numbers and if large > small displays the text in the chosen color. Then returns color to original light grey. However, when I compile I get the following errors:

extraneous `char' ignored - Points to function when I declare it.
extraneous `char' ignored - line 2
expected primary-expression before "char" - Line 5

1
2
3
4
5
6
7
8
9
10
11
1. void colored_text_compare (string text, unsigned short color, int large, int small)
2. {
3.    HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
4.    
5.    if (large > small) 
6.    {
7.       SetConsoleTextAttribute(hcon, color);
8.    }
9.    cout << text << endl;
10.   SetConsoleTextAttribute(hcon,15);
11. }


I've used #include <windows.h> and a variation of this function (minus the compare part) works fine, so I don't know what to think.
I googled the error, but all I got is links that just show a series of errors without explaining what's wrong.
Last edited on
Well the if didn't need the brackets, but I was desperate and I was trying various things and I forgot to erase them when I posted
Please, plaese someone answer. It is so confusing because right above this function
I have the void colored_text function which displays a colored text and works fine.

1
2
3
4
5
6
7
8
9
void colored_text  (string text, unsigned short color)
{
   HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
   SetConsoleTextAttribute(hcon,color);
   cout << text;

   SetConsoleTextAttribute(hcon,15);

}


They are both declared before main()

void colored_text ( string text,unsigned short color );
void colored_text_compare (string text, unsigned short color, int large = 1, int small = 0 );

I give initial values to large, small to have the text colored in the case the user doesn't provide any values. If I get it to work I won't need the void colored_text function
I tried removing the values 1, 0 from colored_text_compare, but nothing changed.
I finaly found the problem. I had named the variables large and small. That was creating all the "extraneous `char' ignored" errors. When I changed them to num1, num2 everything worked OK.
Topic archived. No new replies allowed.