I don't understand why the following code doesn't work as I wanted it to.
char sentence = "this will be capitalised";
for (i=0; i<strlen(sentence); i++)
this will be capitalised
Program ended with exit code: 0
Replace the line:
with this one:
sentence[i] = toupper(sentence[i]);
The problem with your code is that
toupper does not do the conversion in place, instead it returns the converted letter as its return value.
If you don't want to modify the string and you are only want to print it in uppercase form, then use WolfieeifloW's solution.