ok i have tried to get the following piece of code to go from 1 line of char's in a buffer to the next, check to see if the first 6 lines match and if so print out the line
however i am don't know why it dosen't print out correctly
Code:// Cfunctions.cpp: implementation of the functions class. // ////////////////////////////////////////////////////////////////////// #include "functions.h" #include <iostream> #include <windows.h> #include <fstream.h> #include <conio.h> #include <stdlib.h> ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// Cfunctions::Cfunctions() { } Cfunctions::~Cfunctions() { } Cfunctions::Printall() { system("cls"); ifstream file; file.open("flight.txt",ios::nocreate); if(!file) return -1; while(file && !file.eof()) { file.get(ch); switch(ch) { case '~': case '%': case '#': ch = 0; break; } cout << ch << flush; } file.close(); getch(); return 0; } int Cfunctions::Flightdetails() { cout << "Please enter flight number" << endl; cin >> flightno; system("cls"); ifstream is("flight.txt",ios::nocreate); if(!is) return -1; char buffer[48]; char buffer2[48]; do { is.getline(buffer,48, '#'); if (buffer[0] == flightno[0]) { if (buffer[1] == flightno[1]) { if (buffer[2] == flightno[2]) { if (buffer[3] == flightno[3]) { if (buffer[4] == flightno[4]) { if (buffer[5] == flightno[5]) { cout << buffer << endl; } } } } } } else { if (n == 0) { is.seekg(45, ios::beg); n++; } else { is.seekg(45, ios::cur); } } }while(is && !is.eof()); is.close(); return 0; }



LinkBack URL
About LinkBacks


