+ 7
Whats the error here?
I cant find the error https://code.sololearn.com/c4Oy1zF4u2KY/?ref=app
21 odpowiedzi
+ 2
Kindly avoid using gets() because it is not recommended for certain reasons that you can read by yourself online.
You can use fgets().
The code is giving the result you expected. It is counting the number of characters present in the string matching the key.
+ 2
Tnks guys i got it
+ 2
Instead of using built in function you can define one self according to your need
For.eg.
If you want to only input a to z
for(int i=0,c = getchar(); i<size; c = getchar() ) {
if(c <= 'a' && c >= 'z') string[i++] = c;
else break;
}
+ 2
In the input first enter string
And in the next line enter key character
+ 2
But there is no error! It is working quite fine.
P. S. Don't forget that the fgets includes the terminating return character in the string too. It shouldn't cause any problem here though. :)
+ 1
I failed to understand what you were trying to achieve.
+ 1
Nothing. Working fine. Are you not getting the output?
But it's better to fgets instead gets();
+ 1
Jayakrishna it appears the output isn't what he's expecting.
+ 1
Y Åđ Û see Jayakrishna has mentioned it in the last line.
+ 1
Y Åđ Û well then show how you've changed the code
+ 1
Isn't it right🤔 it gives ans
+ 1
It's fine just you need write in two lines:
barca
a
Output: barca has 2 a in it.
+ 1
Hallo
0
I was trying to enter a string...and then enter a character to find its frequency in that particular string
0
Jayakrishna yea that's what confused me
0
Avinesh bruh..wen i use fgets(strimg)
Its not working :/
0
Ruchita Oza i have changed it and made it right
0
Privet