I can't run it because I don't have Turbo C++ but one thing I spotted is that you only allow the username to be one character (a is a char). If you input more than one character the rest of them will be read as the password.
When I enter UserName Dave and password hello, it responds with
cin has "ave"
Looking at line 19, you input only a single character for the username instead of a string. So the rest of the string is in the input buffer and that's what you get when trying to read the username.
Well .. guys .. @Disch - Turbo C++ must be 25 years old but the college uses the software and hence i'm bind to use it .. else i'd had obviously used codeblocks..
@Peter87 and @dhayden ... I have no problem whatever happens in the login function... I just had prob in the ins function in which the cin isn't reading... Thats why i don't usually post my whole code in here.. Okay .. If anybody knows what should I do Please Reply
@dhayden I don't know why .. I've Put the header file as #include<string.h> still when i type string in the code .. it says thats invalid... and when i put #include<string> then one more error rises saying that no header file like that..
Even need help in that situation... Sorry if I annoyed someone... I'm just a beginner , newbie, and maybe noob.. Please reply..
Are your names and passwords a single character? Entering more that a single character for these variables will cause problems because you defined the variables as single characters. If you enter multiple characters for these variables you'll probably have problems later in your program because you'll probably have characters left in the input buffer when you leave the login function. By the way why does the login function always succeed no matter what you try to enter for the password.
Since you're using such an outdated compiler you probably shouldn't try to use a C++ string since that compiler's version of the string class is quite different than the standard C++ string class. You'll be better off using C-strings instead.
I have no problem whatever happens in the login function
Just because it appears to work doesn't mean it is problem free. At line 19 you do this: cin>>a;
Which reads a single character, leaving whatever else you typed for the username in the input buffer. So when you do cin>>f in inp(), it fails because you're asking it to interpret the 2nd-nth characters of the username as a number.
Ahh guys... I said i don't care whatever the login function does.. I just have problem in ins fuction ... Thats where the cin is not reading.. I don't mean to be rude but you guys are stuck at login function yet and i need solution to ins function... Login function doesn't matter to me at all and that is just for a output .. Means just for show.. Showpiece some like that... Please reply for ins function...
Ok sorry .. So you mean i need to correct the login function too .. Oh hell .. Coding's getting tougher and tougher ... Ok what should i do for the login function? Please reply @dhayden
Get your code to run as I have shown and then have a look at the login later. You seem to have a problem related to using crappy Turbo C or whatever it is. You can do real C++ online for free.
Press the gear wheel in the right hand top corner of the code boxes here.