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.............

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.

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.

commented: Good catch +3

Not a problem. Keep mitrmkar's comment in mind too, he makes a good point.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.