help-me, i need a txt line reader.

Hello, before all, be patient with me, i'm very very beginner, sorry my bad english.
I have a class that contains the functions: register, delete and view the register.
when a new person is registered, it saves the name and age of her in a txt.
how to get the name line and stores it in a string, because the way I did it is stored in char.
I have two arrays, the name and the "names".
the array name stores all the names of all people.
the array "names" stores each character of the names of registered persons.
the same thing with age.
how do I read the name and age? putting an int age and name in a string
the code the way I did save the names of persons registered in a txt file named "names.txt" obvious .
it also saves the age of the individuals listed in a txt called "ages.txt" also means obvious.
save's in diferents lines.
Hi TheLeandroNex,

Welcome to the forum :+)

Can we see your code? Remember to use code tags - select your code then press the <> button on the FOrmat: Menu on the right.

Can you put the Names and ages into 1 txt file? This would be easier than having 2 files.

I (and others) look forward to helping you out.
ok, but has a little problem, my entire code is in Portuguese (the language spoken here in Brazil) I used labels just to be easy of identifying where is such a thing, I'll cut them after ready. Before, my script writing names and ages in a txt, a txt for names and a txt for ages but now every time I try to register or delete a person, when you enter the part of writing the txt it closes. But I will translate some things to get better understanding.
Nome(s) = Name(s)
Idade(s) = Age(s)
Dados = Data
registrar = register
Sair = Exit
Carregar = Load
Ver = See
Sobre = About
Deletar = Delete
Nao Registrado = Not Registered
Tempo = Time
Texto = Text
Temp = Temporary
Escolha = Choose
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#include <iostream>
#include <stdio.h>
#include <string>
#include <Windows.h>
#include <fstream>
using namespace std;

class registro{
public:
    int registrar(string Nome[], int Idade[], int line){
    cout << "Digite o nome : ";
    cin >> Nome[line];
    cout << "Digite a idade : ";
    cin >> Idade[line];
    cout << "Nome : " << Nome[line] << endl << "Idade : " << Idade[line];
    }

    void deletar(int line, int max_spaces, int Idade[], string Nome[]){
    system("cls");
    int b = 0;
    int a = 0;
    cout << "Escolha o Registro a Ser Apagado" << endl;
        for (b = 0; b < max_spaces; b++){
            if (a < 10){cout << "[ " << a << " ] " << " Nome : " << Nome[b] << "  Idade : " << Idade[b] << endl;}else if(a >= 10){
            cout << "[ " << a << "] " << " Nome : " << Nome[b] << "  Idade : " << Idade[b] << endl;} a += 1;}
            cin >> b;
            Nome[b] = "Nao Registrado";
            Idade[b] = 0;
            line = b;
            }

    void ver(int max_spaces, int Idade[], string Nome[]){
            int line = 0;
            for (line = 0; line < max_spaces; line++){
                if (line < 10){cout << "[ " << line << " ] " << " Nome : " << Nome[line] << "  Idade : " << Idade[line] << endl;}else if(line >= 10){
                cout << "[ " << line << "] " << " Nome : " << Nome[line] << "  Idade : " << Idade[line] << endl;}}}

    void carregar(string texto, int tempo){
    system("cls");
    cout << texto;
    Sleep(tempo);
    cout << ".";
    Sleep(tempo);
    cout << ".";
    Sleep(tempo);
    cout << ".";
    system("cls");
    cout << texto;
    Sleep(tempo - 10);
    cout << ".";
    Sleep(tempo - 10);
    cout << ".";
    Sleep(tempo - 10);
    cout << ".";
    }
};

main(){
    int anterror = 0;
    int max_spaces = 21; // O NĂºmero que quiser + 1
    int Idade [max_spaces];
    int line = 0;
    int temp = 1;
    int user_input;
    string Nome [max_spaces];
    char * Nomes = new char[max_spaces*3];
    char * Idades = new char[max_spaces*2];
    for (line = 0; line < max_spaces; line++){
            Nome[line] = "Nao Registrado";
            Idade[line] = 0;}
    line = 0;
    Start :
    cout << endl << " ___________________________" << endl;
    cout << "|_________Escolha___________|" << endl;
    cout << "|___________________________|" << endl;
        cout << "|_____[1]_Registrar_________|" << endl;
        cout << "|_____[2]_Deletar_Registro__|" << endl;
        cout << "|_____[3]_Ver_o_Registro____|" << endl;
        cout << "|_____[4]_Sobre_____________|" << endl;
        cout << "|_____[5]_Sair______________|" << endl;
        registro dados;
        cin >> user_input;
        switch(user_input){
    case 1 :
        goto Registrar;
        break;
    case 2 :
        goto Deletar;
        break;
    case 3 :
        goto Registro;
        break;
    case 4 :
        goto Sobre;
        break;
    case 5 :
        goto Sair;
        break;
        }

        Registrar :
        if (anterror = 1){
        dados.registrar(Nome, Idade, line);
        line = temp;
        line += 1;
        temp = 1;
        dados.carregar("registrando", 300);
        anterror = 0;
        goto Data;
        }else{
        dados.registrar(Nome, Idade, line);
        line += 1;
        Sleep(100);
        dados.carregar("registrando", 300);
        system("cls");
        goto Data;}

            Registro :
            dados.ver(max_spaces, Idade, Nome);
            temp = 1;
            Sleep(2000);
            system ("cls");
            goto Start;

                Sobre :
                cout << "Este Programa Foi Feito Por : TheLeandroNex\n"
                            "E-mail : TheLeandroNex \n"
                            "Mande E-mails Caso Encontrar Algum Erro \n"
                            "Esta Versao e : (0.1.0)\n"
                            "A Primeira Versao (0.0.1) Foi Feita Em : 25/04/2014";
                Sleep(3000);
                system ("cls");
                goto Start;

                    Deletar :
                    temp = line;
                    dados.deletar(line, max_spaces, Idade, Nome);
                    anterror = 1;
                    dados.carregar("deletando", 200);
                    system ("cls");
                    goto Data;

                        Sair :
                        exit(0);

                            Data :
                            ofstream fout("names.txt");
                                if(fout.is_open()){
                                    cout << "Aquivo de Nomes Aberto" << endl;
                                        for(int i = 0; Nome[i] != "["; i++)
                                        {
                                        fout << Nome[i] << endl; //escrevendo no txt
                                        }
                                        }else {
                                            cout << "Nao Foi Possivel Abrir o Arquivo De Nomes" << endl;
                                            Sleep(100);
                                            }
                                        ofstream fout1("ages.txt");
                                            if(fout1.is_open()){
                                                cout << "Aquivo de Idades Aberto" << endl;
                                                    for(int i = 0; Idade[i] != 0; i++)
                                                    {
                                                    fout1 << Idade[i] << endl; //escrevendo no txt
                                                    }
                                                    Sleep(100);
                                                    goto Start;
                                                    }else {
                                                    cout << "Nao Foi Possivel Abrir o Arquivo De Idades" << endl;
                                                    Sleep(100);
                                                    goto Start;
                                                    }


return 0;
            }
Topic archived. No new replies allowed.