Tuesday November 15 write single E 711 Lab 92Reading form a
     Tuesday November 15 write single E 7.11 Lab 92-Reading form a Grooey usttom Fle 7.11 Lab 9.2 Reading from a Grocery List from File Due in Lab before 4.30pm crates program 2 compute the totalprioo for al of your groceries Youmame ator 3 wne \"My name is and yourname toan output secaed to the fle output the grocery ist and by side two ookumns proekstside 5 output on a ine soparate 6, the totalprioo for the groomies to the se outpt My name Army Studentboer bananas 250 MacBook Air  
  
  Solution
#include<iostream>
 #include <fstream>
 using namespace std;
 int main() {
    int val, tot=0;
    char name[]=\"yourname\";
    cout<<\"My name is \"<<name<<endl;
    FILE *fn=fopen(\"yourname.txt\",\"w+\");
    fprintf(fn,\"My name is %s\",name);
    fclose(fn);
    FILE *fq=fopen(\"file.txt\",\"a+\");
    std::ifstream file(\"groceryList.txt\");
    std::string s;
    while(file >> s >> val) {
        cout<<s<<\" \"<<val<<endl;
        fprintf(fq,\"%s %d\ \",s.c_str(),val);
        tot+=val;
    }
    cout<<\"\ **************************\";
    fprintf(fq,\"%d\",tot);
    fclose(fq);
 }

