Advertisement
fcamuso

Corso recupero C++ - video 23

Nov 24th, 2022
927
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <iostream>
  2.  
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.  
  9.    cout << "CARICAMENTO ELENCO ALUNNI\n\n";
  10.  
  11.    int num_alunni=0;
  12.    cout  << "Quanti alunni ha la classe? ";
  13.    cin>>num_alunni;
  14.  
  15.    string *p = nullptr;
  16.    p = new string[num_alunni];
  17.  
  18.    //string *p = new string[num_alunni];
  19.  
  20.    int inseriti=0;
  21.    while (inseriti<num_alunni)
  22.    {
  23.      cout << "Inserire il cognome dell'alunno (o STOP per terminare): ";
  24.      cin >> p[inseriti];
  25.  
  26.      if (p[inseriti]=="STOP") break;
  27.  
  28.      inseriti++;
  29.    }
  30.  
  31.    delete[] p;
  32.    p = nullptr;
  33.  
  34.    //if (p!=nullptr)
  35.  
  36.  
  37.     return 0;
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement