Convert char to char*?

1
2
char var1='a';
char *var2= (char *)&var1;


Not working Help!!!
Line 2 should simply be char *var2 = &var1;
No does not work. I want this...

1
2
var1='a';
var2="a";
1
2
char* var2 = new char[1];
var2 = var1;

pogrady, that would be a memory leak even if it would work.
Garu, you should include a null terminator.
That is correct regarding the null terminator.

This string "a" is actually two characters long,

like this:
 
    char array[2] = {'a' , '\0'};
Topic archived. No new replies allowed.