Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 22nd, 2006, 2:48 PM   #1
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
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
Kilo is offline   Reply With Quote
Old May 22nd, 2006, 3:04 PM   #2
Tegelane
Newbie
 
Join Date: May 2006
Location: Estonia
Posts: 8
Rep Power: 0 Tegelane is on a distinguished road
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;
}
Tegelane is offline   Reply With Quote
Old May 22nd, 2006, 3:43 PM   #3
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
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
Kilo is offline   Reply With Quote
Old May 22nd, 2006, 5:55 PM   #4
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
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.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:09 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC