0

Hi, imnewbie to c++ programming. Im want to read some txt file that have a data write inside. The data should be "WAT1235" which is the license plate number. Then if the programming read this data "WTA1234" it will give other information like the Roadtax, Colour of the car and etc. I want to display the output should be like :

OUTPUT DISPLAY:

WTA1235
Information:
Roadtax:.....
ModelCar:.....
etc..

This my coding for the fisrt step read the txt file, but have some error

Inline Code Example Here
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

void main(){

    ifstream inFile;
    inFile.open("test.txt");

    //Check for Error
    if (inFile.fail()){
        cerr << "Error Opening File" << endl;
        exit(1);
    }
    return 0;
}

Any suggestion and discuss will very helpfull.

3
Contributors
2
Replies
18
Views
4 Years
Discussion Span
Last Post by Ancient Dragon
0

void main(){ has never ever ever been correct. int main(){ is.

For your code to work, the executable needs to be in the same directory as the text file you're trying to open. Is it? How do you know?

0

what exactly is the error? compiler error? runtime erro? you get the "6rror opening file" message in your program?

You also need to tell us what compiler and operating system you are using.

Edited by Ancient Dragon

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.