int fileManagerClass::getNextChar() //Precondition: The source file associated with the owning object has // been prepared for reading. //Postcondition: The next character from the input file has been read and // returned by the function. If another chacter could not // be read because END OF FILE was reached then EOF is // returned. { if ((currentLineNumber == 0) || (charToReadNext == strlen(currentLine))) { if (fileToCompile.peek() == EOF) { return (EOF); } lineCounter++; //when it is not EOF but end of a line or when 1st line starts fileToCompile.getline(currentLine, MAXCELLSPERSTRING); strcat(currentLine, "\n"); if (autoPrintStatus == true) //check if the autoPrintStatus is ture to print the current line before moving to next line { printCurrentLine(); } currentLineNumber++; charToReadNext = 0; } return(currentLine[charToReadNext++]); }
int fileManagerClass::getNextChar() //Precondition: The source file associated with the owning object has // been prepared for reading. //Postcondition: The next character from the input file has been read and // returned by the function. If another chacter could not // be read because END OF FILE was reached then EOF is // returned. { if ((currentLineNumber == 0) || (charToReadNext == strlen(currentLine))) { if (fileToCompile.peek() == EOF) return (EOF); fileToCompile.getline(currentLine, MAXCELLSPERSTRING); strcat(currentLine, "\n"); currentLineNumber++; //If a new line is read, print it out if print status is true if(autoPrintStatus) printCurrentLine(); charToReadNext = 0; } return(currentLine[charToReadNext++]); }