Looking for a online tool/application that can read this code

Discussion in 'C++' started by Dellan, Jun 9, 2023.

  1. Dellan

    Dellan New Member

    Joined:
    Jun 8, 2023
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Hi Guys im looking for a tool/application that can read this code::

    Code:
    void create()
    {
        // file pointer
        fstream fout;
    
        // opens an existing csv file or creates a new file.
        fout.open("reportcard.csv", ios::eek:ut | ios::app);
    
     
    
        cout << "Enter the details of 5 students:"
             << " roll name maths phy chem bio";
        << endl;
    
    
        int i, roll, phy, chem, math, bio;
    
        string name;
    
        // Read the input
        for (i = 0; i < 5; i++) {
    
            cin >> roll
                >> name
                >> math
                >> phy
                >> chem
                >> bio;
    
            // Insert the data to file
            fout << roll << ", "
                 << name << ", "
                 << math << ", "
                 << phy << ", "
                 << chem << ", "
                 << bio
                 << "\n";
        }
    }
    
    Can anybody help?
     
    Last edited by a moderator: Jun 10, 2023
  2. palak231

    palak231 New Member

    Joined:
    Sep 9, 2022
    Messages:
    18
    Likes Received:
    1
    Trophy Points:
    3
    Gender:
    Female
    Occupation:
    Software Developer
    Location:
    Haldwani, Uttarakhand
    Home Page:
    https://www.absmartly.com/
    There are some syntax errors with your code. Can you try the below code, It may fix the error you are getting.

    Code:
    #include <iostream>
    #include <fstream>
    using namespace std;
    
    void create() {
        // File pointer
        fstream fout;
    
        // Open an existing CSV file or create a new file.
        fout.open("reportcard.csv", ios::out | ios::app);
    
        cout << "Enter the details of 5 students: roll name maths phy chem bio" << endl;
    
        int i, roll, phy, chem, math, bio;
        string name;
    
        // Read the input
        for (i = 0; i < 5; i++) {
            cin >> roll >> name >> math >> phy >> chem >> bio;
    
            // Insert the data to the file
            fout << roll << ", " << name << ", " << math << ", " << phy << ", " << chem << ", " << bio << "\n";
        }
    
        // Close the file
        fout.close();
    }
    
    int main() {
        create();
        return 0;
    }
    
    Thanks
     
    shabbir likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice