- This topic is empty.
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.
IT, Programming, & Web Development › Forums › CS50’s Introduction to Computer Science by Harvard University on Edx › Week 2: [Arrays] – Functions, Variable and Scope, Debugging, Arrays, and Command Line Arguments › To convert to uppercase
Tagged: scrabble lab problem
I intend to convert word to uppercase. It appears mine is not the correct way. Why it is wrong and how to correct.
[dm_code_snippet background=”yes” background-mobile=”no” slim=”yes” line-numbers=”yes” bg-color=”#abb8c3″ theme=”dark” language=”clike” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
int compute_score(string word) { // TODO: Compute and return score for string string wordU = toupper(word); int x = strlen(word); return x; }
[/dm_code_snippet]
Update:
On second thought, since toupper/tolower works on char type (cs50 manual), it will not work on string type.
Is there any alternative way to make the same work for string?
Or perhaps need to take char one by one and then convert to uppercase.
Reply
https://edstem.org/us/courses/176/discussion/1778073[learn_press_profile]