This is your code, but with some modification
Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void the_switch(int cw);
char *txt_ptr;
int main()
{
int cw;
int v[3];
int i;
int j;
txt_ptr = malloc(80);
strcpy(txt_ptr,"");
v[0]=8;
v[1]=8;
v[2]=555;
v[3]=8;
for (i = 0; i < 4; i++)
{
cw = v[i];
the_switch(cw);
printf("%s\n",txt_ptr);
}
getchar();
return 0;
}
void the_switch(int cw)
{
switch(cw)
{
case 8:
strcat(txt_ptr,"\\x");
break;
case 555:
strcat(txt_ptr,"\\555");
break;
case 444:
strcat(txt_ptr,"\\444");
break;
case 333:
strcat(txt_ptr,"\\333");
break;
default:
strcat(txt_ptr, "\0");
}
}
/*my output
\x
\x\x
\x\x\555
\x\x\555\x
*/
I guess this will do what u want. u need to just change X to 8 to display like \333\8\8 for 333,8,8
ssharish2005