Using the input.txt file below that contains records, where each record consists
ID: 3631955 • Letter: U
Question
Using the input.txt file below that contains records, where each record consists of two fixed length fields. The ID is 3 bytes and Name is 50 bytes.
Finish the program below that reads the ID from a user and then prints the name that
corresponds to the given ID. Assume the records are not sorted and no End of Lines
markers.
input.txt
111aaaaa….444ddddd….555eeeee….666fffff….222bbbbb….
333ccccc……888hhhhh…..777ggggg……999iiiii…..
-----------------------
main() {
char c;
ifstream infile;
infile.open("input.txt",ios::in);
Explanation / Answer
Dear Friend here is the answer without using vectors but can`t make it without using the stdlib.h or i can make a function to do this but still need another library u have a string containing integer and u want separate them this is not as simple as it sound so this is the best and the fastest any to do it and please this thing took time from me and i know this is at least helpfull if u think that there is better than this wain and u will c this is the only solution best regards #include #include #include #include using namespace std; int main() { ifstream infile; char text[53]; int nums[100]; string names[100]; int count=0; int ID; infile.open("input.txt"); while(!infile.eof()) { infile>>text; nums[count]= (atoi(text)); for(int i=0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.