CString 2 integer and reverse
-
Hello, i have a text file where i store a number. When i read the value in my szBuffer(CString) i like to cast this to an integer because i want to increment this value. After the incrementation i like to write the value back into the file. So cast from int to CString(szBuffer) Any ideas, code? Thanks, Mark
-
Hello, i have a text file where i store a number. When i read the value in my szBuffer(CString) i like to cast this to an integer because i want to increment this value. After the incrementation i like to write the value back into the file. So cast from int to CString(szBuffer) Any ideas, code? Thanks, Mark
-
try this: iInteger=atoi(LPCTSTR(csCString)); iInteger++; csCString.Format("%d",iInteger); this should do it! greets, Jason
-
C style: char buf[10]; int number = 5; sprintf(buf, "%d", number); CString bleh = buf; STL style: #include std::ostringstream str; int number = 5; str << number; CString bleh = str.str().c_str(); MFC style: CString bleh; int number = 5; bleh.Format("%d", number); Boost style (www.boost.org): #include int number = 5; std::string str = boost::lexical_cast(number); CString bleh = str.c_str();
-
C style: char buf[10]; int number = 5; sprintf(buf, "%d", number); CString bleh = buf; STL style: #include std::ostringstream str; int number = 5; str << number; CString bleh = str.str().c_str(); MFC style: CString bleh; int number = 5; bleh.Format("%d", number); Boost style (www.boost.org): #include int number = 5; std::string str = boost::lexical_cast(number); CString bleh = str.c_str();
-
try this: iInteger=atoi(LPCTSTR(csCString)); iInteger++; csCString.Format("%d",iInteger); this should do it! greets, Jason