I'm trying to uppercase the keywords in 1d array by using function toupper and additional array, but the code doesn't work properly
My code is:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main () {
char prog1[20], prog2[20];
char ch1, ch2;
int j = 0;
printf ("Enter a prog:");
gets(prog1);
printf ("Enter keywords:");
gets(prog2);
char upper = toupper(ch2);
while (prog1[j])
{
ch1 = prog1[j];
ch2 = prog2[j];
putchar(toupper(ch2));
j++;
}
return 0;
}
The result is:
Enter a prog:aaa bbb ccc
Enter keywords:bbb
BBB`?
The goal is to receive result like this:
Enter a prog:aaa bbb ccc
Enter keywords:bbb
aaa BBB cccc
I would highly appreciate your help