Issues in Console Programming

Pages: 123
I've written a safe, flexible getpassword() function in C which will also work with C++ code. It also demonstrates enabling and disabling line buffering and character echoing. All three of these things are listed as "todo". Would anyone be interested?
I'd like to see the getPassword() function.
They're all the same function. I shall post it soon.
I've been unable to continue ATM, but yes, it is still an ongoing effort. I'll try to get back to it soon. :-)
I'm apprehensive that this article will be used more for evil than for good.

I find I have to beat people with a stick to get them to leave the console because they're trying to do things that they shouldn't be doing in the console. An article like this seems like it will make that worse.
I was writing an article on this but I am too lazy to finish it:
http://www.cplusplus.com/articles/preview/40/


Maybe Disch is right?
@Disch,
And I think that's silly. I have yet to bother to make a program with a real GUI. I don't care for it. The furthest I've gone in the direction of graphics is some miniscule WinAPI programs (< 300 LOC) and messing around with SFML. What's wrong with the CLI? Not every program needs a GUI - it's a waste of time and space for some of them.

@Null,
I'll post it when I get on my actual computer. I'm using parents' laptop at the moment. It will work on Linux and Windows, and maybe Mac OSX although I can't really find out. I'm not sure about DOS.

Edit: It doesn't seem to work on Win32 but definitely worked on Linux.
getpassword.h: http://codepad.org/RXUgiB5Y
getpassword.c: http://codepad.org/JkVp50nQ
main.c (you don't need this): http://codepad.org/FEddJU4f
Last edited on
I have yet to bother to make a program with a real GUI. I don't care for it

I don't blame you. It's a pain. I'm not fond of GUI programming myself.

What's wrong with the CLI?

When used properly, nothing.

I'm not saying people shouldn't use the console. I'm saying people shouldn't misuse the console.

Most (if not all) people asking the kinds of questions this topic addresses are misusing the console.

Here's the most severe case I've seen so far: http://cplusplus.com/forum/beginner/27978/

That thread killed me. Seriously... look at what he was doing.

The pain and hardship that guy was putting himself through was so severe. And because he started with the console and thought it would be easier, he got too stuck in his ways and I wasn't able to convince him to leave, even though he really should not have used the console for that project.


It's like that point on the "smart questions" essay:
http://www.catb.org/esr/faqs/smart-questions.html#goal

The people asking "how do I clear the screen", "how do I change the text color" are asking about the next step, but they're really going about the overall process all wrong. Answering their quesiton is almost a disservice, as it pushes them further down the wrong path instead of putting them on the right one.
Disch wrote:
I don't blame you. It's a pain. I'm not fond of GUI programming myself

I got the impression that you enjoyed it from your previous posts. Personally the thing that puts me off is that it takes about ten lines of code just to say where to put a button, what to write on it, and what to do when it gets clicked. And then you feel bad because you're hardcoding the label, position, size, colours, etc. of all your widgets. It's so complicated.

There are two libraries that I really like for doing "more-than-standard" I/O: SFML and Curses. GTK is horrible and I haven't yet tried Qt. SFML is very simple, very fast, very lightweight, very powerful and very portable. Curses is very simple and flexible as well. GTK+ makes for a nice GUI but I think it's API seems rather broken. Maybe it's just me, but then, I don't want to spend the next year of my life wrapping up XLibs and the Windows API in a way that seems logical to me when it's been done so many times.

Disch wrote:
That thread killed me. Seriously... look at what he was doing.

I agree. Loading images into the console, while a cool party trick, seems very backwards. Having said that, writing console interfaces can be fun. I had one once that loaded a special type of file (I called it .cbm for "Console Bitmap"), drew it on the screen and allowed the player to move around. It never got further than that, though.
Last edited on
Well done, Duoas!
@Duoas,
I've written a (cross-platform) getpassword() function to replace the deprecated UNIX one. It works on both Windows and *nix and is very flexible (though it is written in C, not C++). I could post it if you like. I think you can use parts of the source code for other things (such as disabling line-buffering and character echoing, which it does both of).

Are you interested at all?
Make an article about it and I'll link to it in the topic post.
Ok cool, I'll do it soon.
I just realised I already posted about this (at the top of this page).
Topic archived. No new replies allowed.
Pages: 123