c++
i have little problem how to write a file with reference vector can you help me on this. thank you
- pass vector to a function by Reference - iterate over a vector - write file line by line - use output string stream - use string concatenation - populate vectors with user input contents - use control structures: DO-WHILE, variations of IF-ELSE, FOR, and functions Problem: Your client wishes to have a program that would generate a student database in a form of Excel spreadsheet. In order to save a record to the spreadsheet, client will enter student data at the prompt, one record at a time. Every record in the database is represented by student data; record number, first name, last name, ID, GPA. Your assignment is to write the program that would get user input, one line at the time, and write them to a Comma Separated Values file. In addition, the program will need to save student recor as a single string to a vector of strings, one record at a time. When user is done entering records, program should display all the lines entered by the user to the screen. Design Write a design outline, it does not have to be very detailed, you will add details as you implemen the program. Comma Separated Values File Format The CSV ("Comma Separated Values") file format is often used to exchange data between different applications. - Each record is one line - In this assignment, you can use ' n ' to indicate end of line. - Fields are separated with commas - Duh. - Leading and trailing whitespace is ignored - Always Delimiting - the delimiters will be parsed and discarded by the reading applications like Microsoft Excel. - Example: "1 John, Smith, 12345, 3.5\n " Things to consider when implementing the program: 1. write_file(vector < string > \&v): (1) Open file for writing
(1) Open file for writing (2) check if file can be open for writing (due to memory problems) (3) Prompt user to enter student records. NOTE: number of records is unknown, so program must repeatedly prompt user for input until the user enters "quit". To make this work, extract only the first word from standard input stream buffer (this would be the student's last name) and check it is "quit". (4) Extract the rest of the values from standard input stream: first name, student id, and gpa. (5) use DO-WHILE loop to get user input (6) use output string stream to write to the CSV file (7) NOTE: you should also insert record number to before the student record (figure out how to do that). (8) Add student record to the vector passed in by reference (meaning that the function will modify the original vector) (9) close file when user enters "quit" 2. print_student_info(vector < string > \&v ) This function is different from Lab5 Team assignment. Now, we only have ONE vector to hold student records. Each student record is represented by a single string. This is done because we do not process student data. Vector is used to print student records to console. 3. main() Main function should integrate both the helper functions described above to solve the given problem. NO GLOBAL variables, all variables should be local. Main should print program title, call write_file( ) and print_student_info( ) functions, and print content of the vector to the console. At the end, program should remind user to check student_database.csv file by