Convert a regular char to a pointer to type char? Sure just specify the address of the char with the & operator.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
void letter(char * letter)
{
*letter = 'a';
}
int main()
{
char myletter = 'b';
letter(myletter); // compiler will complain because the function is expecting a pointer to type char.
// you can conver the char to char * by doing this...
letter(&myletter); // the & indicates you are passing the address of myletter which is what a pointer is designed to do, now the function will work and the compiler will keep his mouth shut.
}