944,137 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 327
  • C++ RSS
Nov 4th, 2009
0

help please

Expand Post »
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
C++ Syntax (Toggle Plain Text)
  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
C++ Syntax (Toggle Plain Text)
  1. 8178858588
  2. 8178858588
  3. 2147483647 (where i printed out the return)

can anybody explain this to me?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Brandon515 is offline Offline
16 posts
since Feb 2009
Nov 4th, 2009
0
Re: help please
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?
Reputation Points: 1268
Solved Threads: 228
Posting Virtuoso
vmanes is offline Offline
1,895 posts
since Aug 2007
Nov 4th, 2009
0
Re: help please
ah, right. thx again man.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Brandon515 is offline Offline
16 posts
since Feb 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC