#include "stdafx.h"
#include <iostream>
#include <string>
const int MAX_PRODOTTO = 10;
void registra_prodotto(int MAX_PRODOTTO){
std::string nome_prodotto[MAX_PRODOTTO];
int num_prodotto = -1;
for (int i = 0; i <= (MAX_PRODOTTO-1); i++) {
std::cout << "Inserisci il " << i + 1 << " prodotto: ";
std::cin >> nome_prodotto[i];
//
if (nome_prodotto[i] == "FINE") {
std::cout << "Registrazione prodotti interrotta." << std::endl;
nome_prodotto[i].clear();
break;
if (i > (MAX_PRODOTTO - 1)){
std::cout << "Spazio esaurito!" << std::endl;
}
}
//
num_prodotto += 1;
}
std::cout << std::endl << std::endl << "N. prodotti totali: " << num_prodotto + 1 << std::endl;
std::cout << "Lista della spesa: " << std::endl;
for (int i = 0; i <= (MAX_PRODOTTO-1); i++){
std::cout << nome_prodotto[i] << std::endl;
}
}
int main()
{
std::cout << "Type: ""FINE"" if you want to stop recording products. " << std::endl << std::endl;
registra_prodotto(MAX_PRODOTTO);
std::cout << std::endl;
system("PAUSE");
return 0;
}