Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Feb 27th, 2012  |  syntax: C++  |  size: 0.76 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4. #include "conio.h"
  5.  
  6. using namespace std;
  7.  
  8. #define NUMBEROFCATS 3
  9.  
  10. struct CCat
  11. {
  12.         int id;
  13.         string name;
  14.         string age;
  15.         string food;
  16. };
  17.  
  18. void main()
  19. {
  20.         CCat cats[NUMBEROFCATS];
  21.         string tempstring;
  22.  
  23.         for(int i = 0; i < NUMBEROFCATS; i++)
  24.         {
  25.                 cats[i].id = i;
  26.  
  27.                 cout << "Name\n";
  28.                 getline(cin, tempstring);
  29.                 cats[i].name = tempstring;
  30.  
  31.                 cout << "Age\n";
  32.                 getline(cin, tempstring);
  33.                 cats[i].age = tempstring;
  34.  
  35.                 cout << "Food\n";
  36.                 getline(cin, tempstring);
  37.                 cats[i].food = tempstring;
  38.                 cout << "\n";
  39.         }
  40. _getch();
  41.         for(int i = 0; i < NUMBEROFCATS; i++)
  42.         {
  43.                 cout << cats[i].id << "\n" << cats[i].name << "\n" <<  cats[i].age << "\n" << cats[i].food << "\n\n" ;
  44.         }
  45.         _getch();
  46. }