Plz give me a solution about 'a.out' issue

Question: The positive integer has to be input in the program first, and the program should check if the number exists in the pre-set numbers of the data file. And then, the program has to print out the result → If the number exists among the numbers of the data file, it should print out the line number. Or, if the number doesn't exist among the numbers of the data file, it should print out -1.

***It should be performed in this form: a.out data.txt < in.txt > out.txt


data file ( data.txt ) example:
34
567901
23933
863
55

input ( in.txt ) example:
23933
35

output ( out.txt ) example:
3 //(which means, line number)
-1

DESPERATELY I NEED YOUR HELP. I'M THE BEGINNING PROGRAMMER,
AND I REALLY WANT YOU TO MAKE THE RIGHT PROGRAM FOR ME.
PLEASE GIVE ME THE SOLUTION ABOUT THIS. THANK YOU.
tommytaylorkim wrote:
...I REALLY WANT YOU TO MAKE THE RIGHT PROGRAM FOR ME.
lol no

Show some code of your own. Surely by now you know how to make "Hello, World." Start from there. Instead of printing "Hello, World" though, you'll have to do some different things.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
#include <fstream>  //for dealing with files

int main()
{
    //while reading a line from the input file into 'input' is successful
    //    set an int called 'foundOnLine' to -1
    //    set an int called 'lineCount' to 0
    //    while reading a line from data file into 'data' is successful
    //        increment 'lineCount'
    //        compare 'data' to 'input'
    //        if it matches, set 'foundOnLine' to the value of 'lineCount' and break
    //    end for each
    //    write 'foundOnLine' (plus a newline) to the output file
    //end for each
    return 0;
}
Last edited on
Topic archived. No new replies allowed.