Help with converting char to *char

by sesteve on Thu Nov 17, 2011 10:05 pm

I am trying to read a string of text from text sent from an android phone to a bluesmirf silver mate.
I am using the code below to read a character from the serial and it puts it into a varaiable vl.
I want to send the text to the tft via testdrawtext ... however, if I put a string "info" in place of vl
it works fine but I am having problems sending a letter or number that is vl.
Is there a way to in arduino c to convert vl to a string?

Thank you.

============= code ============================
char vl ;

void loop()
vl =;
testdrawtext(vl, YELLOW);

These are the errors I get:

error: invalid conversion from 'int' to 'char*'
error: initializing argument 1 of 'void testdrawtext(char*, uint16_t)'

Posts: 3
Joined: Thu Nov 17, 2011 9:56 pm

Re: Help with converting char to *char

by cstratton on Thu Nov 17, 2011 11:38 pm

A char* is a pointer to a string or array of char's. Conventionally, a string of this type must be terminated by a null (0) byte.

You can do something like this:
Code: Select all
    char s[2];                       //create an array of two single-byte characters
    s[0] =;   //put single character in first element of array
    s[1] = 0;                        //null terminate
    testdrawtext(s, YELLOW); //display the string
User avatar
Posts: 253
Joined: Wed Sep 29, 2010 2:52 pm