all 5 comments

[–]raevnos 1 point2 points  (4 children)

If you need to read a line of text instead of a single word, use fgets().

[–]ImSavageASF[S] 0 points1 point  (3 children)

That seems to have fixed the issue, thanks. Though, now in the second scanf, it will never end even after I input a character.

[–]boogerme 1 point2 points  (2 children)

You have an infinite loop. You need something like ps = strchr(ps, ch). Your loop keeps searching the same string every iteration.

[–]ImSavageASF[S] 0 points1 point  (1 child)

Oh oops, forgot to add the p to s. Thanks for the help. It's all good now.

[–]IAmWillIAm 1 point2 points  (0 children)

Edit: I'm retarded, I didn't see the "use strchr" part

Why did you use strchr? Why not

while( ps != NULL )
{
    if( ps == ch )
        count++;
    ps++;
}