+ 2
Hiš¤! Can you find a bug in my code?
#include<stdio.h> #include<conio.h> #include<string.h> int count(); int main() { static char enter[20]; gets(enter); printf("sum=%d",count(enter)); getch(); } int count( sum) char *sum; { int count1=0,i=1; while((*(sum+i)!=" ")&&(*(sum+i)!='\n')&&(*(sum+i)!='\t')) { ++count1; i++; } return count1; }
2 Answers
+ 2
Ok, you made a few mistakes which i will point out and then please compare your code with the fixed version.
First, #include<conio.h> and getch(); are uneeded.
Second, dont use gets, use scanf
Third, your while conditions were not set up quite right and you dont use ā ā for space, use ā\0ā
Here is the fixed version of your code.
https://code.sololearn.com/cf2fjR8I8i4x/?ref=app
+ 1
I want to count how many symbols are involved but it doesnāt do rightš„ŗ