# PIC > LCD > Displaying string and int value

#### kawauso

##### New Member
I would like to know how to write :
1) a message like « Bonjour ! Ça va ? »
2) the value of a variable after measuring,
3) the combination of both 1) & 2) like 3,47 volts.
I made some research on the web. I do not want to use only in MikroC the Conversion Library of Mikroelektronika and the void IntToString(void) without being able to watch the code inside and understanding the conversion process.
Some body has a idea or the link to an open source ?
Thanks at all !
Merci à tous.
Eric

#### Pommie

##### Well-Known Member
The standard C library is itoa() (integer to ascii). I found this page which implements itoa() in C++ but easy to convert.

Mike.

#### Ian Rogers

##### User Extraordinaire
Forum Supporter
Here's mine. No comments .. takes an array, a value and a decimal requirement then stores as fixed point number ie.. 900 with 1 decimal = 90.0
It does what I want it to... modify as you see fit..

C:
void printFloat(char * flt, long number, char digits)
{
if(number < 0)
{
number = abs(number);
}
if(digits == 2)
{
flt[0] = number / 1000 + 48;
if(flt[0] == 48) flt[0] = 0x20;
flt[1] = ((number % 1000) / 100)+ 48;
flt[2] = 46;
flt[3] = ((number % 100) / 10)+ 48;
flt[4] = (number % 10) + 48;
flt[5] = 0;
}
else
{
flt[0] = number / 100 + 48;
if(flt[0] == 48) flt[0] = 0x20;
flt[1] = ((number % 100) / 10)+ 48;
flt[2] = 46;
flt[3] = (number % 10) + 48;
flt[4] = 0;
}
}

#### kawauso

##### New Member
Thanks Ian, Rogers.

#### AtomSoft

##### Well-Known Member
Just wondering .. does sprintf work ok micros? I could have sworn I used it before...

NameVariable = Jason
floatDegrees = 78.8
sprintf(buffer, "Hello, %s , it is %f degrees F.", NameVariable,FloatDegrees);

Something like that... Would print

Hello Jason, it is 78.8 degrees F.

Or am I forgetting something

#### Nigel Goodwin

##### Super Moderator
Just wondering .. does sprintf work ok micros? I could have sworn I used it before...

NameVariable = Jason
floatDegrees = 78.8
sprintf(buffer, "Hello, %s , it is %f degrees F.", NameVariable,FloatDegrees);

Something like that... Would print

Hello Jason, it is 78.8 degrees F.

Or am I forgetting something
Of course it works, as long as you have a routine to actually do the printing - which you need to write yourself for whatever 'display' you're using.

However, what you're forgetting is the huge impact of sprintf which takes a LOT of memory space, and runs pretty slowly - it's far more efficient to write a specific routine to do just what you want.

#### Mike - K8LH

##### Well-Known Member
I hate to admit it, but, it's so much easier in Arduino. I added an "LCD" class for my old 2-pin 8-bit LCD Backpack a couple years ago and it was relatively easy to include the Arduino "Print" class for all those neat formatting capabilities... I posted the demo' here on ETO...

Arduino LCD + Print Class demo