#include <iostream>
usingnamespace std;
struct exam
{
char name[15];
int roll;
double grade;
};
int main()
{
exam * p = new exam[3];
\\ how should i initialise the structure members??
cin.get();
}
C++ string literals are arrays of const char, so you can't legally modify them.
Change name to be a const char pointer and it should work.
Well if you don't want to change the type of "name" then you should initialise it as you would an array for characters... i think the way you intialised the other members were fine
Edit:
you can use brace syntax to intialise the name only in C++0x. Otherwise you will have to use a for loop to assign each letter manually
The problem is that you can't assign arrays like that. That's one of the reasons why we often prefer to use std::string instead of raw arrays to store text. If you change the type of exam::name to std::string you will be able to to do it exactly as you wrote it.