Printing from structures

Hello, My class is over but I want to figure out how to print from a structure. In my program the first 28 lines were the example frrom the instructor on structures. He did not show us how to print the structure to teh screen. I have been trying a few things and have not gotten them to work. Right now it complies and asks for the info to put into the structure but does not print it out. I am just wanting to expand my knowledge. Thank you for the help

#include <iostream>
using namespace std;

typedef struct
{
   char name [100];
   int age;
   char power [100];

}SuperHero;

int main ()

{
    int count;
   SuperHero my_hero [3]; //creates array of 3 superheros

   for (int x = 0; x < 3; x++)
   {
       cout << "Enter name" << endl;
       cin >> my_hero [x].name; // stores super heros name into name. x is the number of the location for each superhero 1,2,3

       cout << "Enter age" << endl;
       cin >> my_hero[x].age;

       cout << "Enter power" << endl;
       cin >> my_hero[x].power;

      for (int x=0; count <= 3; count++)
      {
           cout << "Name: " << my_hero[x].name << endl;
           cout << "Age: " << my_hero[x].age << endl;
           cout << "Power: " << my_hero[x].power << endl;
      }


   }

}
for (int x=0; count <= 3; count++)

What value does count have at the start?...
Last edited on
Thank you very much. I got it fixed and it works great. I replaced count with x and moved the second for loop out of the first one. Thanks again
Topic archived. No new replies allowed.