I was trying to convert uppercase to lowercase, but am encountering segmentation fault while executing the code
BElow is the code:-
#include<stdio.h> #include<ctype.h> #include<string.h> int main(){ char a[10]; int i; printf("Enter a string.\n"); gets(a); printf("Converting it to upper case.\n"); for(i=0;i<10;i++){ printf("%s\n",toupper(a[i])); } puts(a); return 0; }
And here's the output Iam getting:-
Enter a string. hello world Converting it to upper case. Segmentation fault (core dumped)