+ 1

Why is k always 0

#include <stdio.h> #include <string.h> main() { char ch1,p[30]; int k,i,j; printf("please enter a string") gets(p) printf("please enter a letter") scanf("%s",&ch1); for(i=0;i<strlen(p);i++) if(p[i]==ch1) k++; printf("num count is %d,k") }

7th Aug 2021, 4:30 PM
5 ответов
+ 5
You have many mistakes like semi-colon missing, wrongly printed k and also we should not use gets in modern compiler. https://code.sololearn.com/cErQryHvbV2D/?ref=app
7th Aug 2021, 4:41 PM
A͢J
A͢J - avatar
+ 3
Thanks ❤
7th Aug 2021, 6:42 PM
MEHMET_HAMDI
MEHMET_HAMDI - avatar
+ 2
Mehmet_Hamdi Sololearn doens't support Swing.
7th Aug 2021, 6:28 PM
A͢J
A͢J - avatar
+ 1
https://code.sololearn.com/cV1x96E3zraT/?ref=app Simple help...the code is working on the laptop, but it shows an error on the site!!!!
7th Aug 2021, 6:01 PM
MEHMET_HAMDI
MEHMET_HAMDI - avatar
+ 1
Thanks
10th Aug 2021, 8:51 PM