DWA1
asked on
How can I get the first three numbers from a long value
Ok lets say I had a long variable that was something like this
long mylong = 12823450;
Now what I am wanting to know is how can I just get 128 from that long.Thanks for your time and help.
long mylong = 12823450;
Now what I am wanting to know is how can I just get 128 from that long.Thanks for your time and help.
theres a typo in the scanf statement, there should be a '&' before 'myNumber'.
Sorry
Sorry
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks to you all.Gj62 that was what I was looking for,thanks.
ex. char myNumber[20] = {1,2,8,2,3,4,5,0};
or
char myNumber[20];
scanf("%s",myNumber);
then to get the first three numbers, have another char array:
char smallNumber[3];
for(i = 0; i < 3; i++)
{
smallNumber[i] = myNumber[i];
}
then store the array to an integer:
long myLong;
myLong = atoi(smallNum);
try that, I hope this helps
--JSand