![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Expert Programmer
|
Parsing Int from String
I have tried atoi() but i get errors!
s_numUp = itoa(atoi(Trim(tempParse))); Error. 1>c:\documents and settings\knowell\my documents\visual studio 2005\projects\sed\sed\sed.cpp(500) : error C2664: 'atoi' : cannot convert parameter 1 from 'std::string' to 'const char *'
__________________
"When in Rome, Do as the Romans Do" "Beauty is in the eye of the BEER holder" "Save your breath your going to need it for your blow up doll later" SearchLores.org |
|
|
|
|
|
#2 |
|
Newbie
Join Date: May 2006
Location: Estonia
Posts: 8
Rep Power: 0
![]() |
you could use std::string.c_srtr() methon on the string to get a char*
or you could use stringstreams for converting #include <string>
#include <sstream>
#include "netstatus.h"
int makeint(const std::string& str) {
std::stringstream ss;
int tmp;
ss<<str;
ss>>tmp;
return tmp;
} |
|
|
|
|
|
#3 |
|
Expert Programmer
|
already fixed thanks! (i just didn't use anything)
__________________
"When in Rome, Do as the Romans Do" "Beauty is in the eye of the BEER holder" "Save your breath your going to need it for your blow up doll later" SearchLores.org |
|
|
|
|
|
#4 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Bear in mind, for future reference, that itoa takes three parameters, not one, and does not return a string or a pointer to a character array. That said, string streams are more useful anyway.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|