I have made a following program that will convert lower case letters in to upper case and upper case letters will remain same and that will be done Realtime (as character is typed).
#include<stdio.h>
#include<conio.h>
void main(void)
{
char ch;
printf("Type a sentence: ");
while (ch!='\r')
{
ch=getch();
if (ch >=97 && ch <= 122) // if lowercase
ch = ch -32; // change to lowercase
printf("%c",ch);
}
getch();
}
But now I want to add an option that, user enters a character number to capitalize.
Following should be output of the program:
Enter sentence: hello how are you?
Enter char number to capitalize: 2
Output: hEllo hOw aRe yOu?
Any help? I don't know how to get the position of character in a string.
P.S. I don't want to use any other library function or string.