I'm having trouble storing a char sequence array of a defined length in to an object of a struct. I can make it work without defining a char length or just using a string but it just bothers me why this is happening.
The code:
#include <iostream>
#include <string>
using namespace std;
struct highscore {
char name[50];
int score;
char date[10];
} hstable[9];
void printtable (highscore show_tab) {
cout << show_tab.name << show_tab.score << show_tab.date;
};
void main() {
hstable[0].name = "Kyle ";
hstable[0].score = 100;
hstable[0].date = " 01/03/88 \n";
printtable (hstable[0]);
system("pause");
return;
};
Error :
error C2440: '=' : cannot convert from 'const char [6]' to 'char [50]' 1> There is no context in which this conversion is possible
error C2440: '=' : cannot convert from 'const char [12]' to 'char [10]'