1For those of you who want to uppercase a string and store it in a variable (that was what I was looking for when I read these answers).
2
3#include <stdio.h> //<-- You need this to use printf.
4#include <string.h> //<-- You need this to use string and strlen() function.
5#include <ctype.h> //<-- You need this to use toupper() function.
6
7int main(void)
8{
9 string s = "I want to cast this"; //<-- Or you can ask to the user for a string.
10
11 unsigned long int s_len = strlen(s); //<-- getting the length of 's'.
12
13 //Defining an array of the same length as 's' to, temporarily, store the case change.
14 char s_up[s_len];
15
16 // Iterate over the source string (i.e. s) and cast the case changing.
17 for (int a = 0; a < s_len; a++)
18 {
19 // Storing the change: Use the temp array while casting to uppercase.
20 s_up[a] = toupper(s[a]);
21 }
22
23 // Assign the new array to your first variable name if you want to use the same as at the beginning
24 s = s_up;
25
26 printf("%s \n", s_up); //<-- If you want to see the change made.
27}
28//If you want to lowercase a string instead, change toupper(s[a]) to tolower(s[a]).
1int result = toupper(charecterVariable);// return the int that corresponding upper case char
2//if there is none then it will return the int for the original input.
3//can convert int to char after
4char result2 = (char)toupper(variableChar);