when i compiled this, it returned me an error = lvalue required. I tried to change the char to string but still no luck. Seriously this char thing pissed me off..please help me. Thanks in advance!!!
What Moschops says. Don't use C-type strings if you can avoid it, because they are very confusing for beginners.
If you're curious about what the error exactly means: arrays are basically pointers. stud_1.first is a pointer to stud_1.first[0], i.e. the first element of stud_1.first. That means the line stud_1.first = "James";
translates to "change the address of stud_1.first to "James"". The RHV doesn't make much sense, but the compiler will do his best to translate the string literal "James" into an address. It'll be useless, but okay. The LHS, however, is unmodifiable. In essence, you're saying "move stud_1.first to a different position in memory".
hmm, i used Borland C++, if that helps anything. Anyway, so i put the string header and compile it...success but the cmd prompt doesn't show anything when i run it.
Is it not showing anything, or closing immediately?
it doesn't show anything but blank output....
I think if you're learning, you should use a C++ compiler that conforms to the C++ standard. There are many free IDEs and compilers that do so.
i thought borland c++ is similar with the rest of the compilers...anyway, my course used it so i have no choice but to stick with it. So, is there any ways to solve this matter? I downloaded some notes regarding on structures and they used char instead of string...!'m a bit confused at first since using char caused me error! so, either the notes wrong or me myself just sucks at programming..
Ok, done compiling...showed some buildtime msgs...when i run it, it only shows the line 16 till i pressed any key, then the name showed up....so line 16 >> press any key >> "James" shows up
line 16 >> press any key >> "James" shows up
It is likely caused by the buffering of cout.
Makes your line 17 cout << stud_1.first << flush; or cout << stud_1.first << endl;