Hi there,
could someone help me please, Ive just stared with c and I want the function to accept upto 50 characters but finish when i hit return and then to change the case of them.
It continues to accept characters after i have hit return up until the array of 50 is finished.
My next problem is that it seems to loop outside the loop and repeat the whole process again from the initial printf statement.
any suggestions would be great.
MAX_LINE_LENGTH = 50
Code:int inverseCharacters() { char ch[MAX_LINE_LENGTH]; int i= 0; printf("%s", "\nEnter a line of text combining upper and lower case: \n"); //scanf("%s", &ch); while (i <= MAX_LINE_LENGTH) { ch[i]= getchar(); if(islower(ch[i])) { ch[i] = toupper(ch[i]); putchar(ch[i]); } else { ch[i] = tolower(ch[i]); putchar(ch[i]); } i++; } return 0; }