convert int to string (itoa don't work)

C, C++, and Visual C++
Nds

convert int to string (itoa don't work)

Postby Nds » Mon Dec 28, 2009 10:48 am

Hi,
I was trying to convert the value of a sensor (int) in a string
to assign to a key in the dictionary.

Using itoa (), the compiler returns:

Code: Select all

/ tmp/cctD1e20.o: In function `SensorChangeHandler ':
fw_dict2.c: (. xffc text +0): undefined reference to `itoa '
collect2: ld returned 1 exit status


I have converted with sprintf some individual char (0/1) but with strings (% s) instead of (%c) the program end with no error.

Code: Select all

char buf[10];
sprintf(buf,"%s",Value);
CPhidgetDictionary_addKey((CPhidgetDictionaryHandle)dict,"Luce",buf,0);

How i can achive this?

Regards
Nds

Nds

Re: convert int to string (itoa don't work)

Postby Nds » Mon Dec 28, 2009 11:19 am

Done,

I have wrong the sintax of the sprintf, simply a %d instead of a %s.

Regards
Nds


Return to “C/C++”

Who is online

Users browsing this forum: No registered users and 2 guests