18 Answers
New Answer#include <stdio.h> int main() { int i=0; char a[100]; printf("enter uppercase word to convert in to lower case:-\t"); gets(a); while(a[i]!='/0') { if(a[i]>='A' && a[i]<='Z') { a[i]=a[i]+32; } i++; printf("\n lower case word is:%s",a); } return 0; }
2/28/2021 5:00:41 AM
Parthik18 Answers
New AnswerHere are the list of things you did wrong 1) gets() is deprecated (use fgets() or scanf for taking input) 2) Used '/0` instead of '\0' ( as pointed out by I Am AJ ! ) 3) putting final output inside the loop ( not necessarily an error but looking at program I don't think that was what intended to be done here ) Here's the fix π https://code.sololearn.com/cnyw3N9AONfg/?ref=app
Parthik Sonagara There is '\0' not '/0' Use fgets instead of gets #include <stdio.h> #define MAX_LIMIT 100 int main() { int i=0; //char a[100]; printf("enter uppercase word to convert in to lower case:-\t"); //gets(a); char a[MAX_LIMIT]; fgets(a, MAX_LIMIT, stdin); while(a[i]!='\0') { if(a[i]>='A' && a[i]<='Z') { a[i]=a[i]+32; } i++; printf("\n lower case word is:%s",a); } return 0; }
Parthik Sonagara When everything updates in the world then programming languages also get updates. New features comes and old features deprecate. That's why same for gets.
Arsenic in your code, there is still a possibility to have a buffer overflow (due to scanf). But you can do : scanf("%99s", a); It will take at maximum 99 chars.
The code runs just fine in other app with gets() why is it happening Arsenic Théophile I Am AJ !
Parthik Sonagara Will work here also but gets() function now deprecated means no longer use.
srikanth vuppala yeah i figured it out later if we use this structure then output will show conversation of uppercase to lowercase latter by latter
Bina mistake kr to aadmi aadmi nhi bnta fir to ye code hai galtiyan hoti rhti hai. Bolo jai shree ramπ₯π₯ππποΈποΈβ₯οΈβ₯οΈ
SoloLearn Inc.
4 Embarcadero Center, Suite 1455Send us a message