In one file we have employee number and salary and in another file we have employee number and designation . Now in the output file i want to print salary and designation with corresponding employee number ?

Recommended Answers

Probably the fastest way to do that is to read all of file2 into an in-memory array(s). Then start reading file1 line by line. Read a line, search file2 array for employee ID, when found print to third file or to screen. Repeat that for each line in file1.

That …

Jump to Post

All 4 Replies

Probably the fastest way to do that is to read all of file2 into an in-memory array(s). Then start reading file1 line by line. Read a line, search file2 array for employee ID, when found print to third file or to screen. Repeat that for each line in file1.

That might be optimized if both files are sorted by employee ID, such as you would not have to read file2 into memory first.

Exactly how to do that will depend on what programming language you will use.

DSA Students File Handling
[1]Add
[2]View
[3]Exit

DSA Students File Handling
Name:James Bill
Age:35
Course:BSIT
Subject1:Math
Subject2:English
Subject3:Science

Grade in English=80
Grade in Math=80
Grade in Science=80

Record 1BSIT
James Bill 35yrs old
Grade in English=80%
Grade in Math=80%
Grade in Science=80%

Anyone knows how to do solve this problem.

Anyone knows how to do solve this problem.

Yes, don't you? Please post your attempts (code) to solve it.

here's a trivial example based on linux ....

Desktop:~/code/scripts$ cat sal
23 45000
33 54000
Desktop:~/code/scripts$ cat des
23 manager
33 director
Desktop:~/code/scripts$ join des sal
23 manager 45000
33 director 54000
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.