char array to string
-
Hi, I have a char array with 2 elemts.
char c[2]; c[0] = 0x10; c[1] = 0x06;
I want a string that will hold "1006". How can I do that? Thanks.You could use _stprintf[^] or if you're using MFC, look at CString::Format()[^]
It is a crappy thing, but it's life -^ Carlo Pallini
-
Hi, I have a char array with 2 elemts.
char c[2]; c[0] = 0x10; c[1] = 0x06;
I want a string that will hold "1006". How can I do that? Thanks.char str[5];
sprintf(str, "%02X%02X", char[0], char[1]);«_Superman_» I love work. It gives me something to do between weekends.
modified on Wednesday, May 20, 2009 2:12 AM
-
Hi, I have a char array with 2 elemts.
char c[2]; c[0] = 0x10; c[1] = 0x06;
I want a string that will hold "1006". How can I do that? Thanks. -
Good one. Simple and nice.
«_Superman_» I love work. It gives me something to do between weekends.
-
char str[5];
sprintf(str, "%02X%02X", char[0], char[1]);«_Superman_» I love work. It gives me something to do between weekends.
modified on Wednesday, May 20, 2009 2:12 AM
-
char str[5];
sprintf(str, "%02X%02X", char[0], char[1]);«_Superman_» I love work. It gives me something to do between weekends.
modified on Wednesday, May 20, 2009 2:12 AM
I see a flaw in your code (I supposed supeheroes flawless... :rolleyes:). :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
I see a flaw in your code (I supposed supeheroes flawless... :rolleyes:). :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]Oooops. Ahem! Actually I leave that to the compiler. :-\
«_Superman_» I love work. It gives me something to do between weekends.