I am trying to create a program where it will read in the student name, nationality, and grades, and calculate their tuition fee based on those information.
I began to write a bit of code by I have ran into some problems. When I try to run my code, the compiler says "warning C4700: local variable 'name' used without having been initialized" but continues to run the code. Then the program shuts down. What is happening?
In addition, on my fifth line I have "char *firstName;". I know that char* represents a pointer, but what does that mean and why can't I just use a string?
#include <iostream>
using namespace std;
struct Student {
char *firstName;
char *lastName;
bool canadianship;
int grades[10];
};
Student newStudent[10];
void addFirstName() {
char *name;
cout << "Student Name: ";
cin >> name;
newStudent[0].firstName = name;
}
int main() {
addFirstName();
cout << newStudent[0].firstName;
return 0;
}