GLYLIB  0.3.0b
scan_file.c
Go to the documentation of this file.
00001 // Function written by B. Lachele Foley, 2007
00002 #include <mylib.h>
00003 //#include "../inc/mylib.h"
00004 
00005 /***************** sscan_file *******************/
00006 /* scans file for number of matches to string s */ 
00007 int sscan_file(FILE *FS,const char *s){
00008 int sfr=0,sfck=1;
00009 char sfs[250];
00010 
00011 sfck=fscanf(FS,"%s",sfs);
00012 while (sfck!=EOF) {
00013         if(strcmp(sfs,s)==0){
00014                 sfr++;
00015                 }
00016         sfck=fscanf(FS,"%s",sfs);
00017         }
00018 rewind(FS);
00019 
00020 return sfr;
00021 }
00022 
00023 /***************** cscan_file *******************/
00024 /* scans file for number of matches to character c*/ 
00025 int cscan_file(FILE *FC,char c){
00026 int cfr=0;
00027 char cfck=0;
00028 
00029 cfck=fgetc(FC);
00030 while (cfck!=EOF) {
00031         if(cfck==c){cfr++;} 
00032         cfck=fgetc(FC);
00033         }
00034 rewind(FC);
00035 
00036 return cfr;
00037 }
 All Classes Files Functions Variables Typedefs Defines