xxxxxxxxxx
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
// Open the file for reading
ifstream inputFile("data.txt");
if (!inputFile.is_open()) {
cerr << "Failed to open the file." << endl;
return 1;
}
string name;
int value;
while (inputFile >> name >> value) {
cout << "Name: " << name << ", Value: " << value << endl;
}
// Close the file
inputFile.close();
return 0;
}