I’ve got some lines of information from a data-file in C++. One information is a 12 character long number. How can I convert this from string to long long (I think long long is most suitable for this) without data loss?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In C++, there is no
long longdata type. It’s available in C99. However, you can useint64_t. Include<stdint.h>.Use
boost::lexical_castto convert string intoint64_t.Or you can write a convert function yourself as:
Test code:
Output:
Online demo : http://ideone.com/nnSLp