How to convert CString to int
-
inVariable=_ttoi(CStringVariable) or even better sscanf(CStringVariable, "%d", intVarible); -Steven Hicks
CPA
CodeProjectAddict
Actual Linux Penguins were harmed in the creation of this message.
More tutorials: Ltpb.8m.com: Tutorials |404Browser.com (Download Link)
-
inVariable=_ttoi(CStringVariable) or even better sscanf(CStringVariable, "%d", intVarible -Steven Hicks
CPA
CodeProjectAddict
Actual Linux Penguins were harmed in the creation of this message.
More tutorials: Ltpb.8m.com: Tutorials |404Browser.com (Download Link)
-
See the FAQ 6.3 How can I change a number into its string representation, or vice versa?[^] --Mike-- Ericahist | CP SearchBar v2.0.2 | Homepage | 1ClickPicGrabber New v2.0! | RightClick-Encrypt "Linux is good. It can do no wrong. It is open source so must be right. It has penguins. I want to eat your brain." -- Paul Watson, Linux Zombie
-
See the FAQ 6.3 How can I change a number into its string representation, or vice versa?[^] --Mike-- Ericahist | CP SearchBar v2.0.2 | Homepage | 1ClickPicGrabber New v2.0! | RightClick-Encrypt "Linux is good. It can do no wrong. It is open source so must be right. It has penguins. I want to eat your brain." -- Paul Watson, Linux Zombie
Hi Mike, I presume, the code snippet below can convert a string to long, and is the most fastest method. ConvertStringToLong( char* szFieldValue,long &lValue ) { //Validate the string :) int nLength = sizeof(unsigned long); char szBuffer1[ 8 ]; char szBuffer[ 8 ]; szBuffer1[nLength] = '\0'; memset( szBuffer1,0,nLength ); szBuffer[nLength] = '\0'; memset( szBuffer,0,nLength ); memcpy((void*) (szBuffer1 + nLength - stringLength ),szFieldValue,stringLength ); for( int i=0;i
-
Hi Mike, I presume, the code snippet below can convert a string to long, and is the most fastest method. ConvertStringToLong( char* szFieldValue,long &lValue ) { //Validate the string :) int nLength = sizeof(unsigned long); char szBuffer1[ 8 ]; char szBuffer[ 8 ]; szBuffer1[nLength] = '\0'; memset( szBuffer1,0,nLength ); szBuffer[nLength] = '\0'; memset( szBuffer,0,nLength ); memcpy((void*) (szBuffer1 + nLength - stringLength ),szFieldValue,stringLength ); for( int i=0;i
-
Um, there must be a ton of stuff missing from this routine because it won't compile and I can see a few ways I can get it to crash. Tim Smith I'm going to patent thought. I have yet to see any prior art.
I know Tim, You can crash it very easily, B'coz I haven't freed the memory, and there are a couple of other mistakes as well. But my intention was only to, break the conventional approach on converting a string to int. Its just stupid to think that, someone else will do all the jobs for U. You may have to correct the mistakes, if thr are any. "A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."