I am working my way through approaching the scrabble problem from PSET2. Right now I just want to focus on getting all my string inputs transferred over to uppercase and then having their values between 0 and 25 so I can compare them against the point array and add them all together.

#include <ctype.h>
#include <cs50.h>
#include <stdio.h>
#include <string.h>

int main(void)

    int sum = 0;
    string s = get_string("Type word:");
    for(int i = 0, n = strlen(s); i < n; i++)
        sum = sum + (toupper(s[i]-65));
        printf("%i", sum);

when I type 'a" in the input. I still get a return value of 32 indicating that my 'a' isn't being changed into 'A' during my sum calculation. What am I doing wrong?



If you give that 'a', then 'a' - 65 is 32. toupper(32) will simply be 32, since 32 is not an ascii char.

Be careful with your ()


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .