I'm trying to get what I put in the value for the database to output, however whenever I use a cout statement with the a.name I get an error on line 21 which is the line with the cout statement. I've done it the way it is in the examples of my textbook so I don't understand what is going wrong.

#include <iomanip>
#include <iostream>
using namespace std; 

 struct Student
  {
	string name;
	string address;
	string city;
	string state;
	string zip;
	string gender;
	string id;
	float gpa;
  } a, b, c;

int main()
{
  a.name = "John";

  cout << a.name;

  cout << "Press ENTER to continue..." << endl;
  cin.get();

  return 0;
}

Recommended Answers

All 2 Replies

You forgot to include <string> header file.

Thanks. I didn't even realize that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.