I'm still a bit rusty on programming, and I have never seen these debugger complaints before.
GNU GCC in Code::Blocks
Source code:
The errors that the debugger are throwing are :Code:#include <iostream> #include <fstream> using namespace std; int main() { int cc=0; int accumilator=0; int counter=0; int lngb=0; int count=0; string IN; /* IN now needs to be converted to a C style string so that it can be manipulated easier and compared to what is read from the file. */ int lng= IN.length(); char in [lng]; do { in[lngb]=IN[lngb]; lngb++; } while (cc<lngb); // Time to find out what word we're looking for: cout<<"Enter word to search file for.\n\n"; cin>>IN; //Get the text data from the file. ofstream file_read ("A.txt"); int F_Read_Length=file_read.length(); char cstring [F_Read_Length]; //Remember your safe coding practices. if (file_read.is_open()) { do { //Convert the data from file to c style string: cstring[counter] = file_read[counter]; counter++; } while (counter<F_Read_Length); } else { //oops cout<<"Program fail on primary file read. File could not be opened. Quitting. \n\n"; return 0; } //Time to compare: do { /* If what came out of the file equals what was entered, accumilator in incremented by one for each character.*/ if (in[count]==cstring[count]) { accumilator++; } else { // Otherwise, we lose one. accumilator --; } count++; } while(count<lngb); if (accumilator==lng){ cout<<"Perfect match.\n\n"; } else { cout<<"Match not found.\n\n"; } return 0; }
error: 'struct std:fstream' has no member named length
and
error: no match for 'operator[]' in 'file_read[counter]'



1Likes
LinkBack URL
About LinkBacks
fstream' has no member named length


