fork download
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4. using namespace std;
  5.  
  6. struct Agenda{
  7. char nome[50];
  8. int cod;
  9. };
  10.  
  11. int main()
  12. {
  13. Agenda a[3];
  14.  
  15. for(int i=0;i<3;i++){
  16. cout << "Nome: ";
  17. cin.get(a[i].nome, 50);
  18. cout << "Cód: ";
  19. cin >> a[i].cod;
  20. cin.ignore();
  21. }
  22.  
  23. for(int i=0;i<3;i++){
  24. cout << a[i].nome << "\t" << a[i].cod << "\n";
  25. }
  26.  
  27.  
  28.  
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0s 15232KB
stdin
texto1
1111
texto2
2222
texto3
3333
stdout
Nome: Cód: Nome: Cód: Nome: Cód: texto1	1111
texto2	2222
texto3	3333