baash05
baash05

Reputation: 4516

Do people actually still use cin and cout?

This is totally an opinion question. More for chatter. I'm taking some c++ tests and they are littered with cin and cout's.
Do people acutally still use these. I mean I've not seen one in an actual public application ever.

The last question I answered in a test was

int c1;
cout << "Enter numbers: " << flush;
for(int n = 0; cin >> c1; ++n){
   cout << c1 << endl;
}
When does this end.. 

The correct answer was "when a user hits ctrl+Z". Where in the heck would I press control+Z? I'm assuming in the terminal, I suppose. But honestly. I've not seen the terminal for ages and ages. And I'm sure as heck not going to attempt to program anything for it.

Are questions like this still relevant, in any of our lives?

Upvotes: 5

Views: 4160

Answers (13)

01100110
01100110

Reputation: 2344

I use std::cin, std::cout and std::cerr daily. Systems programming lacks GUIs.

Upvotes: 0

Pietro M
Pietro M

Reputation: 1939

In my opinion, to write a complex piece of software, it is a good approach to separate the GUI from the rest, i.e., in general, the rest must be able to work even without the GUI.

In this case it can be convenient to manage I/O with cin/cout.

Upvotes: 3

Two Bit Gangster
Two Bit Gangster

Reputation: 993

I've worked on many professional applications and we've not used cin or cout on any of them, even for logging/debugging. Why? Because the stateless *printf methods work perfectly well. One thing I've learned over the years is that stateless trumps statefull for maintainability.

Upvotes: 2

Doug T.
Doug T.

Reputation: 65599

It would be more acceptable, from a language standpoint, if the answer to "when will this program end" was "when EOF is received". Just because "Control-Z" is EOF in DOS, does not mean Ctrl-Z is the right answer.

Edit Edited with comment info.

Upvotes: 1

dirkgently
dirkgently

Reputation: 111130

Do people acutally still use these. I mean I've not seen one in an actual public application ever.

Define public application. What do you think the command line tools on any *nix use? And yes, we too use them, for our SDKs (at least cout and cerr). cin is often not the best when you have complex enough input -- you are left to write a lexer and a parser of sorts.

Upvotes: 2

Dave Van den Eynde
Dave Van den Eynde

Reputation: 17405

I'd rather use wcin and wcout, at least you get the Unicode stuff.

Upvotes: 2

Bill the Lizard
Bill the Lizard

Reputation: 405745

If you only ever write GUI or Web applications in your career you probably won't have much use for cin and cout. If you ever write anything embedded you'll change your position. You just use a different set of libraries for console apps, text-based apps, GUI apps, and Web apps.

Upvotes: 2

Daniel Bruce
Daniel Bruce

Reputation: 11537

Of course it's relevant.

Many automation and admin scripts on a variety of servers rely on text output/input, for example. This is especially true on *nix systems, not as much on windows now that Powershell has come about with its fancy object support.

Then there are the ones of us (a dying breed, I admit) that pretty much LIVE in the terminal. I use the terminal for about 70-80% of my work. I just find it more natural, faster and more powerful than most related GUI apps.

Upvotes: 6

Beno&#238;t
Beno&#238;t

Reputation: 16994

No, such questions are not very relevant, but yes, people use std::cin and std::cout all the time. Even the ones who design graphical interfaces may use cout for debugging !

Upvotes: 12

Joonas Pulakka
Joonas Pulakka

Reputation: 36577

Terminals are widely used, and will be used. The reason is that, when used skillfully, they're far more powerful than any GUIs.

Upvotes: 22

Alex Reitbort
Alex Reitbort

Reputation: 13696

So you want to say that you are a programmer and never used or wrote console application?

Upvotes: 6

Bharani
Bharani

Reputation: 303

Yes, as long as console applications exist, cout and cin will exist.

Upvotes: 9

Mehrdad Afshari
Mehrdad Afshari

Reputation: 421988

Yes, you might want to process or transform an input text file. It'll prove handy.

Upvotes: 4

Related Questions