Hi,i need help with c++ TASK

Hi i need to make program but dont know how i am using wxDev-c++ and i need to make.

Tasks would include:
use a class or struct variable, and create a program that can perform the following actions:
1. The data provided by the user to enter the keyboard.
2. The display of the stored data.
3. edit the data.

Example of data:
name surname age.

I Try like it,its let me input and save it but how to edit it or i am doing it bad?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include<iostream>
#include<fstream>
using namespace std;

int main()

{

            char name[50], sur[50];
            int a;

            ofstream outfile("C:\\info.txt");

            cout << "Name:";
            cin >> name;
            outfile << "Name:" << name << endl;
            
             cout << "Sur:";
            cin >> sur;
            outfile << "sur:" << sur << endl;

            cout << "Age:";
            cin >> a;
            outfile << "Age:" << a << endl;

            outfile.close();

            return(0);

}
Hi, first of all the text of the exercise does not say anything about saving the data to a file: is it necessary?
Secondly you are not using a class nor a struct...

I would do it as follows:
- create a class called, for example, Person which has three fields: name, surname and age
- create getters and setters methods for the fields: getters are useful to print information and setters can be easily used to edit data
- in the main function I would create a collection of object Person (a vector would be ok) and I would start taking the input, printing, etc.

Let me know if you need more help.
Bye.
Topic archived. No new replies allowed.