📅 2022-11-02T13:30:40.255Z
👁️ 95 katselukertaa
🔓 Julkinen


using namespace std;

#include <iostream>
#include <string.h>
#include <fstream>

char type;

int save_contact(string name, string email) {
    std::ofstream outfile;

    outfile.open("tiedot.txt", std::ios_base::app); 
    outfile << name << "\t" << email << "\n"; 
    return 0;
}

void ask_contact() {
    string name;
    string email;

    do
    {
        cout << "\nNimi: " << endl; 
        cin >> name;

        cout << "Sähköpostiosoite: " << endl;
        cin >> email;

        cout << "Ovatko tiedot oikein? [k/e]" << endl;
        cin >> type;
    }
    while( type !='k' && type !='K' );

    save_contact(name, email);
}

int main() {
    cout << "Pääsy myönnetty!\n\n";
    cout << "Onnittelut! Olisiko sinusta ?\n";
    cout << "Jätä yhteystietosi :\n";

    ask_contact();

    cout << "\nKiitos osallistumisesta !\n";
    return 0;
}