Please help why all characters are not showing | SoloLearn: Learn to code for FREE!

+3

Please help why all characters are not showing

Cpp problem https://code.sololearn.com/cpMCsYpxboDm/?ref=app

cpp

2/27/2021 7:24:10 AM

Nirmal

16 Answers

New Answer

+7

1. Initialize I or remove str[i]==35 2. str[i] is true when is equal to 35 means # but it is _ and I is not initialized 3. Cin take a string until a place comes so if you want to get entire line use getline method After applying these points your code will work properly

+4

Avengers please take help from my brother HARDIK JAIN HARSORA [Akshat] πŸ‘πŸ‘

+3

πŸ₯‡πŸ†HARSH JAIN HARSORA [{( CHOTU )}]πŸ†πŸ₯‡ please help

+3

Avengers if something like this is entered "___###_#_#_#___#", then at position 0 , we have '_' , so here loop will never run , also that 0 isn't confirmed as you haven't initialized it with a value, it could be some garbage value as well. and what is charwithspace and charwithoutspace ?? is this program suppose to check for spaces or hashes(#) ??

+3

Avengers if '_' denotes for empty space then you should check for '_' instead of ' ' , right ?

+3

Avengers and remove that "if str[i]==35" which isn't really helping at all and stopping program execution if starting character isn't "#"

+2

The question statment you specified here is different from the one that exist in your code. What exactly is the question here ? As of why you code is not displaying anything right now for the test input you provided, then (as already specified by Abhay )it is because the value of *i* in unitialised at line 13 " if(str[i] == 35) " ( leading to undefined behaviour ) If you are looking a way to count number of characters with and without spaces seperately Then why don't you just traverse the input string once and keep track of both counts accordingly. Sometimes like this : for(i=0; str[i]!='\0'; i++) { countWithSpace++; if(str[i] != '_') countWithoutSpace++; }

+1

Abhay please help Arsenic please help

+1

Avengers why " if(str[i]==35) " ?, Why are you checking if character at position 0 is "#" or not

+1

Bro _ denotes spaces Like String would be " ### # # # #" like this and I want to check the total no of characters with and without space

+1

Ooh right I got confused πŸ˜… Thanks

0

I thought it would only check if # character is entered..if not it would leave..

0

Thanks bro But it doesn't count for input 1 __#_####_## Means when it starts from undersore

0

Thank you so much

-1

I want someone to help me make this application

-1

l want to learn every thing about C++ from zero to the end