Complicated string question (c++); can you solve it?
Okay, I've got a string of words, and I am converting each letter into it's ascii value and putting it into another string, so basically my second string is a long string of ascii values such as (75342357353245436) etc. I need to convert this to an int. But the int value comes out as something completely different, like (83434236). I've tried atoi, atol, nothing works. Any solutions? I'd really appreciate it.
回答 (4)
75342357353245436 exceeds the maximum value of integer, try to convert it into "long long" instead of "int".
I don’t know much about c++
But this has to do with the maximum length of a int value
I think the value 75342357353245436 is two long to be stored in a int
Try finding out the value ranges of int in c++
integer is a 2 or 4 byte variable and the number you were using was too large for that datatype and that would result to the maximum number in the integer data type, try another data type like double or even use an array of integers.
收錄日期: 2021-05-01 01:01:26
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20081124235822AAsrnCu
檢視 Wayback Machine 備份