I have been trying to uppercase the first letter of a string which is inside an array of strings I tried a lot of methods but none of them worked here is my code:
#include <stdio.h>
#include <stdlib.h>
int nw=0;
char words[30][50];
int main(){
printf("enter your words when you finish write b\n");
do{
nw++;
scanf("%s",&words[nw]);
}while(strcmp(&words[nw],"b")!=0);
printf("%s",toupper(&words[1][0]));
}
what should I do please help
For starters you need to include headers
<ctype.h>
and<string.h>
There is no great sense to declare these variables
in the file scope. They could be declared in
main
.Instead of this call
you have to write at least
The condition in the do-while statement should look like
And instead of this call'
you should write
Here is a demonstrative program.
The program output is