I'm not understanding what each line of code is doing exactly. I need to be able to add a little to it. Basically it's turning echo off, but I need to take the input after that then turn echo back on, all in one function so I can call that function like you would cin.
to call it like cin you can wrap the function into a class, maybe even a functor if those are still in vogue, and overload the >> operator to do the silent read code. I haven't done a functor in so long I can't recall if you can overload an operator with them. A regular class will do for it, if not.
then you end up with something like
cins >> input; //cin secure, or cin silent? Name it what you will, of course.
Is it possible to define functions in a preprocessor directive?
I've tried with no luck but it may have been syntax or something.
@jonnin
I'm not good with classes yet but that may work for the preprocessor directive idea. maybe?
@everyone
I think that the preprocessor directives may be the only solution to this so basically at compile time the compiler will only look at the function for the OS doing the compiling. Either way it would end up with the same function but defined differently per OS, essentially creating a cross-platform source but a platform-dependent binary? What do you guys think?
The password input is not showing but it says access denied every time and the limit is no longer working, it just repeats the promt for username and password.
EDIT: I removed getPASS = PASS; and changed if (USER == "josh" and PASS == "hsoj") to if (USER == "josh" and getPASS() == "hsoj") and it works perfectly now!
EDIT 2: Also removed string PASS; from line 7 because it's no longer needed.
The preprocessor will let you have 2 versions of the code, and swap between then when you compile on the various operating systems.
the class can take the above and abstract it into something that looks like cin so you can have the syntax consistency if you wanted that. This is just a code-pretty, calling a function to get the data is exactly the same thing. You might learn something from it, but its totally unnecessary fluff. These things can become necessary in huge projects where making the code easy to write and read is critical to making it work and getting it done.