help please

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Feb 2009
Posts: 13
Reputation: Brandon515 is an unknown quantity at this point 
Solved Threads: 0
Brandon515 Brandon515 is offline Offline
Newbie Poster

help please

 
0
  #1
Nov 4th, 2009
hey guys, ok here's the situation. i need to turn a C++ style string into an integer now i've used altoi and strtol but they give me different numbers. heres my code
  1. cout << file << endl << file.c_str() << endl; // debugging purposes
  2. num = strtol(file.c_str(), &pEnd, 10); // actual conversion
  3. return num; // return

and my output is
  1. 8178858588
  2. 8178858588
  3. 2147483647 (where i printed out the return)

can anybody explain this to me?
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 1,679
Reputation: vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold 
Solved Threads: 193
vmanes's Avatar
vmanes vmanes is offline Offline
Posting Virtuoso
 
0
  #2
Nov 4th, 2009
What's the largest value that can be stored in a long int?

How does that limit compare to the value you're trying to stuff into a long int?
Everyone's gotta believe in something. I believe I'll have another drink.
~~~~~~~~~~~~~~~~~~
Looking for an exciting graduate degree? Robotics and Intelligent Autonomous Systems (RIAS) at SDSM&T See the program brochure here.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 13
Reputation: Brandon515 is an unknown quantity at this point 
Solved Threads: 0
Brandon515 Brandon515 is offline Offline
Newbie Poster
 
0
  #3
Nov 4th, 2009
ah, right. thx again man.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 209 | Replies: 2
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC