Click here to Skip to main content
15,917,568 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
#included every header file (i think)
C++
int main(int argc, char* argv[])
{
  unsigned long long x=atoi(argv[1]);
  unsigned long long y=atoi(argv[2]);
  if(x>0 && x<=4294967295 && y>0 && y<=4294967295)
  {
    cout<<"done";
  }
  else
  {
    cout<<"not done";
  }
  return 0;
}


// But when i insert x=6543848485 or any value greater than 2254354363(10 digit)...
// It is automatically taking the default value of x=2147483647(automatically)... I donot y... and not entering in the else condition...

please help
Posted
Updated 4-Sep-11 21:46pm
v2

Could it possibly be because atoi returns an integer? As in a signed, 32 bit quantity? And 2147483647 just happens to be 7FFFFFFF in hex? I.e. The largest number that fits in a signed, 32 bit integer?
 
Share this answer
 
atoi[^] is not appropriate for dealing with such big numbers. Use strtol[^] instead.
 
Share this answer
 
Comments
Trick7 5-Sep-11 4:01am    
how strtol can be used in c++
Philippe Mori 5-Sep-11 8:57am    
Read the documentation of the function!
But when i run that code in Windows environment. then its running perfectly fine...
 
Share this answer
 
Comments
Philippe Mori 5-Sep-11 8:59am    
This is not an answer. Either "Improve question" or click "Have a Question or Comment?" link below the question to ask for clarification.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900