[Solved] Reading a text file [closed]


  • Open file
  • using fgets or get line function read the file into temporary string
  • check first character… Make sure to use tolower, before comparing

    void findString(char *filename, char ch)
    {
      char temp[100];
      FILE *infile = fopen(filename, "rw");
      while(infile != NULL)
      {
        fgets(temp,100,infile);
    
        if(tolower(temp[0]) == ch)
           cout << temp;
      }
      fclose(infile);
    }
    

solved Reading a text file [closed]