0

Since I don't know how to uppercase function in c, I decided to make it myself. One of pset2 lecture, he taught how to make it also. So this is my code. However, I keep getting error message, very first int is wrong. What should I have to fix?? Thank you!

int UpperCase(void);

int main() { printf("What is your name ");
string name = GetString(); {
printf("Your initials are: %c\n", UpperCase(name)); } }

int UpperCase(void){

char x='\0';
if(x>='a' && x<='z')
x=x-32;

}

1
  • how come it only highlight certain amounts of my code..
    – jayko03
    Jan 14 '16 at 4:07
1

You can use the function toupper(), but be sure to include the header file ctype.h together with stdio.h.

Your function above will not compile for a couple of reasons:

  1. UpperCase takes an integer argument, so it shouldn't be UpperCase (void)
  2. name is a string, so you cannot pass it to UpperCase as an argument. You need to loop through name (which is an array, so you can access individual elements) to convert each element
  3. main should return 0 upon successful completion, while UpperCase should return the converted element
1
  • I didn't know that there is toupper(). I am still trying to coding, but I feel I do not have to make myown uppercase function. Thank you!
    – jayko03
    Jan 15 '16 at 2:06

You must log in to answer this question.

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