Originally posted by Unregistered
Wonder if Typecasting really helps here.
like char_var=(char)int_value;
??
In a word... no. The int value, eg 65, would be assigned directly to the char variable, and when printed using type %c would represent the character of the ASCII value (or whatever you OS uses). In this case the letter A would be printed.
What would happen to the number if the value of the int was >255 (max unsigned char value)? It would overflow, and the value would be lost.
Also, a char is not a string, it's only a single character.
Code:
#include <stdio.h>
/* Example of incorrect conversion from int to char */
int main(void)
{
char c;
int i = 65;
printf("i is %d\n", i);
c = (char)i;
printf("c is %c, %d\n", c, c);
return (0);
}