I am writing the frequency
function for pset 3, and I'm taking the input string note
and storing the character that denotes the octave number in an integer called octave1
. I've been getting some pretty funky outputs so used the debugger to investigate. I've also used eprintf
to double check that my stored value of octave1
is correct.
int octave1;
octave1 = note[1];
eprintf("The octave1 is: %c\n", octave1);
I've tested my function by doing the following:
~/workspace/pset3/music/ $ ./notes 5
helpers.c:179: The octave1 is: 5
And according to eprintf
it seems that my stored octave1
is correct. but in my debugger it shows that octave1
has actually been stored as 52??!! (see screenshot below)
This explains the weird outputs I've been getting but I don't understand how 52 was generated.
Any help will be gratefully received!
'5'
has a value of53
, not52
. And if you use%i
to show integers, you'll see it also ineprintf
.caesar
andvigenere
, there you might have subtracted65
or'A'
in some cases.