You probably want a short or an unsigned short then.
Quzah.
You probably want a short or an unsigned short then.
Quzah.
Hope is the first step on the road to disappointment.
I guess the next question is what is the proper way to convert from a string to an int.
Example:
I enter this random number: 0001010101100111
It should output this:
S: 0001010101100111
1: 1110101010011000
2: 0001010101101000
This is what I get:
S: 1001111001001111
1: 0110000110110000
2: 1001111001010000
I am using the atoi function to convert a string to an int. What should I do?
Well your S isn't looking like what you expect, unless you messed up your example text. You probably want to use something like strtol instead of atoi.
Quzah.
Hope is the first step on the road to disappointment.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
Even if I do something less like 13:
S: 0000010001001101
1: 1111101110110010
2: 0000010001001110
When it should be:
S: 0000000000001101
1: 1111111111110010
2: 0000000000001110
I am using the atoi function.
Thanks,
Mike
I'm not sure what "S" is representing here. Is that your input string? What sort of input are you providing? Remember, atoi is going to give you an int, wich is 32bits on your system. So you're going to need to shift some of that away. Also keep in mind shifting signed vs. unsigned is probably different.
Quzah.
Hope is the first step on the road to disappointment.