fork download
  1. #include <stdio.h>
  2. #define SIZE 80
  3. int count(char *c, char x);
  4. int main(void)
  5. {
  6. char a[SIZE]={0};
  7. int ch,w;
  8. printf("문자열을 입력하세요: ");
  9. gets(a);
  10. printf("개수를 셀 문자를 입력하세요: ");
  11. scanf("%c", &ch);
  12. w=count(a,ch);
  13. printf("%c의 개수 : %d\n", ch, w);
  14. return 0;
  15. }
  16. int count(char *c, char x)
  17. {
  18. int i, count;
  19. count=0;
  20. for(i=0;c[i]!=NULL;i++)
  21. {
  22. if(c[i]==x)
  23. count++;
  24. else
  25. continue;
  26. }
  27. return count;
  28. }
  29.  
  30.  
  31. 출처: https://i...content-available-to-author-only...y.com/80 [인천확대경]
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
asdasdasdasdasdasd
compilation info
prog.c: In function ‘main’:
prog.c:9:5: warning: implicit declaration of function ‘gets’; did you mean ‘fgets’? [-Wimplicit-function-declaration]
     gets(a);
     ^~~~
     fgets
prog.c:11:13: warning: format ‘%c’ expects argument of type ‘char *’, but argument 2 has type ‘int *’ [-Wformat=]
     scanf("%c", &ch);
            ~^   ~~~
            %lc
prog.c: In function ‘count’:
prog.c:20:13: warning: comparison between pointer and integer
 for(i=0;c[i]!=NULL;i++)
             ^~
prog.c: At top level:
prog.c:31:1: error: stray ‘\354’ in program
 출처: https://inhwascope.tistory.com/80 [인천확대경]
 ^
prog.c:31:2: error: stray ‘\266’ in program
 출처: https://inhwascope.tistory.com/80 [인천확대경]
  ^
prog.c:31:3: error: stray ‘\234’ in program
 출처: https://inhwascope.tistory.com/80 [인천확대경]
   ^
prog.c:31:4: error: stray ‘\354’ in program
 출처: https://inhwascope.tistory.com/80 [인천확대경]
    ^
prog.c:31:5: error: stray ‘\262’ in program
 출처: https://inhwascope.tistory.com/80 [인천확대경]
     ^
prog.c:31:6: error: stray ‘\230’ in program
 출처: https://inhwascope.tistory.com/80 [인천확대경]
      ^
prog.c:31:7: error: expected identifier or ‘(’ before ‘:’ token
 출처: https://inhwascope.tistory.com/80 [인천확대경]
       ^
prog.c: In function ‘main’:
prog.c:11:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%c", &ch);
     ^~~~~~~~~~~~~~~~
stdout
Standard output is empty