Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4
Avengers please take help from my brother HARDIK JAIN HARSORA [Akshat] 👍👍
27th Feb 2021, 8:08 AM
🤘🐀HARSH JAIN 🐀🤘
🤘🐀HARSH JAIN 🐀🤘 - avatar
+ 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(#) ??
27th Feb 2021, 8:41 AM
Abhay
Abhay - avatar
+ 3
Avengers if '_' denotes for empty space then you should check for '_' instead of ' ' , right ?
27th Feb 2021, 9:51 AM
Abhay
Abhay - avatar
+ 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 "#"
27th Feb 2021, 10:33 AM
Abhay
Abhay - avatar
+ 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++; }
27th Feb 2021, 11:22 AM
Arsenic
Arsenic - avatar
+ 1
Avengers why " if(str[i]==35) " ?, Why are you checking if character at position 0 is "#" or not
27th Feb 2021, 8:19 AM
Abhay
Abhay - avatar
0
Thank you so much
28th Feb 2021, 8:44 AM
Srady Osman
Srady Osman - avatar
- 1
I want someone to help me make this application
28th Feb 2021, 8:44 AM
Srady Osman
Srady Osman - avatar
- 1
l want to learn every thing about C++ from zero to the end
28th Feb 2021, 8:48 AM
Srady Osman
Srady Osman - avatar