i'm having problem in executing this statement....
error expression syntax

switch(col)
    {
            case 1:text[]={"0x00000000"};
        break;
            case 2:text[]={"0x00FFFFFF"};
        break;
            case 3:text[]={"0x0000FF00"};
        break;
            case 4:text[]={"0x00FF0000"};
        break;
            case 5:text[]={"0x00C000C0"};
        break;
            case 6:text[]={"0x000000FF"};
        break;
            case 7:text[]={"0x0000FFFF"};
        break;
            case 8: text[]={"0x00FFFF00"};
        break;


    }


char text[10] is global.

please help me out.............

Edited 3 Years Ago by Reverend Jim: Fixed formatting

Use strcpy to copy those values into the character array:

#include <cstring> //to access strcpy
switch(col)
{
   case 1:  strcpy(text,"0x00000000");
   break;
      //etc.
}

You can only assign text to a character array in the manner that you are trying when it is first declared.

Edited 6 Years Ago by jonsca: n/a

char text[10]

You need to increase the size of that array by one, if you intend to copy a literal such as "0x00000000" into it (you must account for the terminating '\0' character). Otherwise, you'll be writing out of bounds, which is not allowed.

PS. Maybe consider using std::string s instead of char arrays.

Comments
Good catch
This question has already been answered. Start a new discussion instead.