Hi guys,
I'm new to C++ and I'm doing a small project, I got a little problem with reading a specific number from a text file.
for example:
size 2 3
I want my program to read the 2 to a and the 3 to b. Also I want the user to input the store number and then I can look for this number in my file to give him all the information he wants.
fro example;
Store 1
Available Soft drinks: 24
Pepsi/ 7up: 12/12
Store2
info..
I want to go the required store and show the user the information he wants.
Attached is what I have done so far though it's still not working.
I really appreciate ur help.
thanks :)
#include <iostream>
#include <fstream>
using namespace std;
int main () {
int m, n, x,y, store;
ifstream file;
file.open ("file.txt");
if (!file1){
cout << "Unable to open file"; // if file doesn't exist
exit(1);
}
m = file.get();
n = file.get();
cout << "Enter the store number you want to know about it? " << "\n";
cin >> x;
fscanf(file, "%store", x);
cout << "You have: " << y << "Pepsi" << "\n";
cout << "You have: " << y << "7yp" << "\n";