STL string
-
IS there a way I can do the analogous of sprintf for a char * to a STL string . or a Format for a CString Basically i want to write a integer value to a string ! string numText; char data[20]; int a =100; sprintf(data,"Num is %d",data); Is there a way to do this for the string numText !!!!
-
IS there a way I can do the analogous of sprintf for a char * to a STL string . or a Format for a CString Basically i want to write a integer value to a string ! string numText; char data[20]; int a =100; sprintf(data,"Num is %d",data); Is there a way to do this for the string numText !!!!
you could try:
string numText; char data[20]; int a = 100; sprintf(data,"Num is %d",a); numText = string(data); // this copies the char array into the string
-Nathan --------------------------- Hmmm... what's a signature? -
IS there a way I can do the analogous of sprintf for a char * to a STL string . or a Format for a CString Basically i want to write a integer value to a string ! string numText; char data[20]; int a =100; sprintf(data,"Num is %d",data); Is there a way to do this for the string numText !!!!
Tkae a look at This article[^]
-
IS there a way I can do the analogous of sprintf for a char * to a STL string . or a Format for a CString Basically i want to write a integer value to a string ! string numText; char data[20]; int a =100; sprintf(data,"Num is %d",data); Is there a way to do this for the string numText !!!!
int main(int argc, char* argv[])
{
ostringstream s;
int a = 100;
s << a;
string numText = s.str();
cout << numText << endl;return 0;
}Oh, you also need to include the iostream and sstream headers. Kevin
-
IS there a way I can do the analogous of sprintf for a char * to a STL string . or a Format for a CString Basically i want to write a integer value to a string ! string numText; char data[20]; int a =100; sprintf(data,"Num is %d",data); Is there a way to do this for the string numText !!!!
Use a
ostringstream
.Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
Tkae a look at This article[^]
And on Windows CE .NET? The STL implementation there lacks the handy streams... -- Human beings, who are almost unique in having the ability
to learn from the experience of others, are also remarkable
for their apparent disinclination to do so. (Douglas Adams) -
And on Windows CE .NET? The STL implementation there lacks the handy streams... -- Human beings, who are almost unique in having the ability
to learn from the experience of others, are also remarkable
for their apparent disinclination to do so. (Douglas Adams)Johann Gerell wrote: And on Windows CE .NET? You would use .NET classes anyway. Otherwise, whats the point of using a .NET platform?
Who is 'General Failure'? And why is he reading my harddisk?!?
-
Johann Gerell wrote: And on Windows CE .NET? You would use .NET classes anyway. Otherwise, whats the point of using a .NET platform?
Who is 'General Failure'? And why is he reading my harddisk?!?
jhwurmbach wrote: You would use .NET classes anyway No. ".NET" is a product name here, the .NET framework need not have anything to do with it, but it can. In our specific case, (a) the compact framework (.NET CF) is buggy and unusable and (b) we do drivers and low level stuff unapropriate for the CF. jhwurmbach wrote: Otherwise, whats the point of using a .NET platform? Since it's the latest version of Windows CE, it offers greater security, better Internet connectivity, more stability and about a gazillion other stuff of interest to mobile developers. -- Human beings, who are almost unique in having the ability
to learn from the experience of others, are also remarkable
for their apparent disinclination to do so. (Douglas Adams) -
jhwurmbach wrote: You would use .NET classes anyway No. ".NET" is a product name here, the .NET framework need not have anything to do with it, but it can. In our specific case, (a) the compact framework (.NET CF) is buggy and unusable and (b) we do drivers and low level stuff unapropriate for the CF. jhwurmbach wrote: Otherwise, whats the point of using a .NET platform? Since it's the latest version of Windows CE, it offers greater security, better Internet connectivity, more stability and about a gazillion other stuff of interest to mobile developers. -- Human beings, who are almost unique in having the ability
to learn from the experience of others, are also remarkable
for their apparent disinclination to do so. (Douglas Adams)Wow! .NET CF comes without .NET. Microsoft marketing is working really hard on creating a strong brand. I did not know that. And on top of it, you do not even get a C++ compiler (that would include iostreams), just a surrogate. It seems you are stuck with sprintf.
Who is 'General Failure'? And why is he reading my harddisk?!?
-
Wow! .NET CF comes without .NET. Microsoft marketing is working really hard on creating a strong brand. I did not know that. And on top of it, you do not even get a C++ compiler (that would include iostreams), just a surrogate. It seems you are stuck with sprintf.
Who is 'General Failure'? And why is he reading my harddisk?!?
jhwurmbach wrote: And on top of it, you do not even get a C++ compiler (that would include iostreams), just a surrogate :(( jhwurmbach wrote: It seems you are stuck with sprintf Believe me, I'm so aware of that fact... -- Human beings, who are almost unique in having the ability
to learn from the experience of others, are also remarkable
for their apparent disinclination to do so. (Douglas Adams)