fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(int argc, char *argv[]) {
  5. char count;
  6. char z,x;
  7. int intz;
  8. FILE *file;
  9. file=fopen("text.txt","r");
  10. if(file==NULL) return 1;
  11. printf("Enter char to search in file:\n> ",file); // Как здесь задать вывод имени файла file, заданного на две строчки выше?
  12. scanf("%c",&x);
  13. // FSymCnt(file,x);
  14. while(fgets(z,1,file)){
  15. if (strsrt(x,z)) count++;
  16. printf("%c",z);
  17. }
  18. printf("\nEntered char counted %d times.\n",count);
  19.  
  20. fclose(file);
  21. return 0;
  22. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function 'main':
prog.c:11:9: warning: too many arguments for format [-Wformat-extra-args]
  printf("Enter char to search in file:\n> ",file);  // Как здесь задать вывод имени файла file, заданного на две строчки выше?
         ^
prog.c:14:14: warning: passing argument 1 of 'fgets' makes pointer from integer without a cast [-Wint-conversion]
  while(fgets(z,1,file)){
              ^
In file included from prog.c:1:0:
/usr/include/stdio.h:622:14: note: expected 'char * restrict' but argument is of type 'char'
 extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
              ^
prog.c:15:7: warning: implicit declaration of function 'strsrt' [-Wimplicit-function-declaration]
   if (strsrt(x,z)) count++;
       ^
prog.c:7:6: warning: unused variable 'intz' [-Wunused-variable]
  int intz;
      ^
prog.c:14:8: warning: 'z' may be used uninitialized in this function [-Wmaybe-uninitialized]
  while(fgets(z,1,file)){
        ^
prog.c:18:2: warning: 'count' may be used uninitialized in this function [-Wmaybe-uninitialized]
  printf("\nEntered char counted %d times.\n",count);
  ^
/home/vhWLlC/ccsHP7ZK.o: In function `main':
prog.c:(.text.startup+0x6a): undefined reference to `strsrt'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty