Why does this program prints extra garbage values | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why does this program prints extra garbage values

Its a program to convert lower case letter to upper case https://code.sololearn.com/c1kzi6x6nPWg/?ref=app

11th Sep 2020, 7:43 AM
Prashant Pandey
Prashant Pandey - avatar
3 Answers
+ 7
You need to change your for loop condition to this: for(n=0;s[n]!='\0';n++){ } you need to use: '\0' instead of '0' also use: int main() not: void main() Here's the fix code https://code.sololearn.com/cMZghU7Zx06s/?ref=app
11th Sep 2020, 7:54 AM
Aakaanksha 💕 [TheBraveCoders]
Aakaanksha 💕 [TheBraveCoders] - avatar
+ 1
You wrote s[I] != 0 but it should be s[i] != '\0' ...
11th Sep 2020, 7:56 AM
Jayakrishna 🇮🇳
+ 1
Oh thanks
11th Sep 2020, 8:04 AM
Prashant Pandey
Prashant Pandey - avatar