I have recently started to study C++ and I have already faced many problems. This is something I can't get solved on my own.
1st the program asks the user to type in his/her ID (string). Then it will be splitted in 3 parts: day, month and year. The program is able to set every 3 parts into the correct variables in the correct form but after it starts to write data on the next variable, the previous data vanishes.
1. The program writes the correct day into the "day" -variable.
2. cout << day; prints the correct day.
3. The program writes the correct month into the "month" -variable.
4. cout << day; prints nothing.
So what have I done wrong?
Here is my code (all this is in the main -function):
string ID; cout << "Type in your ID: "; cin >> ID; char day; char month; char year; day = ID; day = ID; day = '\0'; cout << day << endl; month = ID; month = ID; month = '\0'; year = ID; year = ID; year = '\0'; cout << day << "." << month << "." << year << endl;
EDIT: The whole code actually starts to fail after it has written the day -part...