fork download
  1.  
  2. #include "stdafx.h"
  3. #include <iostream>
  4. #include <string>
  5.  
  6. const int MAX_PRODOTTO = 10;
  7.  
  8.  
  9. void registra_prodotto(int MAX_PRODOTTO){
  10. std::string nome_prodotto[MAX_PRODOTTO];
  11. int num_prodotto = -1;
  12.  
  13.  
  14.  
  15. for (int i = 0; i <= (MAX_PRODOTTO-1); i++) {
  16.  
  17. std::cout << "Inserisci il " << i + 1 << " prodotto: ";
  18. std::cin >> nome_prodotto[i];
  19.  
  20. //
  21.  
  22. if (nome_prodotto[i] == "FINE") {
  23. std::cout << "Registrazione prodotti interrotta." << std::endl;
  24. nome_prodotto[i].clear();
  25. break;
  26. if (i > (MAX_PRODOTTO - 1)){
  27. std::cout << "Spazio esaurito!" << std::endl;
  28. }
  29. }
  30.  
  31.  
  32. //
  33.  
  34. num_prodotto += 1;
  35.  
  36. }
  37.  
  38.  
  39.  
  40. std::cout << std::endl << std::endl << "N. prodotti totali: " << num_prodotto + 1 << std::endl;
  41. std::cout << "Lista della spesa: " << std::endl;
  42.  
  43.  
  44. for (int i = 0; i <= (MAX_PRODOTTO-1); i++){
  45.  
  46. std::cout << nome_prodotto[i] << std::endl;
  47.  
  48. }
  49. }
  50.  
  51.  
  52.  
  53. int main()
  54. {
  55.  
  56.  
  57.  
  58.  
  59.  
  60. std::cout << "Type: ""FINE"" if you want to stop recording products. " << std::endl << std::endl;
  61.  
  62. registra_prodotto(MAX_PRODOTTO);
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81. std::cout << std::endl;
  82. system("PAUSE");
  83. return 0;
  84.  
  85. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:2:20: fatal error: stdafx.h: No such file or directory
 #include "stdafx.h"
                    ^
compilation terminated.
stdout
Standard output is empty