Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

C++ Console Question

Name: Anonymous 2007-10-13 15:24

I need to read characters from the console in my C++ program.

Is there any way to do this without utilizing the Win32 API? Google fails me.

Name: Anonymous 2007-10-13 15:30

I need to read characters from the console in my Scheme program.

Is there any way to do this without utilizing the Win32 API? Google fails me.

Name: Anonymous 2007-10-13 15:39

I need to read characters from the console in my Lambda Calculus expression.

Is there any way to do this without utilizing an API? Google fails me.

Name: Anonymous 2007-10-13 15:44

I need to read characters from the console in my Visual Basic program.

Is there any way to do this without utilizing the Linux API? Yahoo fails me.

Name: Anonymous 2007-10-13 15:50



    I need to read characters from the console in my C# program.

    Is there any way to do this without utilizing the Java API? Ask Jeeves fails me.

Name: Anonymous 2007-10-13 16:07

I need to record characters from the Character Input Panel™ in my Java solution.

Is there any way to accomplish this without utilizing the Win32 scalable API? Google fails me.

Name: Anonymous 2007-10-13 16:27

>>6

String line = new BufferedReader(new DataInputStream(CharacterInputPanelFactory.createInstance<CharacterInputPanelInstance>().getInputStream())).getLine();

Name: Anonymous 2007-10-13 16:44

I need a scalable turnkey application that reads text from DOS on my desk by this afternoon.

Is there any way to do this without utilizing both an application server and a database server?  The consults I have asked failed me.

Name: Anonymous 2007-10-13 16:55

You'll need to hire two more managers and a team of consultants for both to do that.

Name: Anonymous 2007-10-13 17:13


#include <iostream>
#include <iterator>
#include <algorithm>
#include <string>
#include <vector>
...
char word[256];
cin >> word;

string word;
cin >> word;

string line;
cin.ignore();
getline(cin, line);

vector<string> words;
copy(istream_iterator<string>(cin),
     istream_iterator<string>(),
     inserter(words, words.begin()));


Just a bunch of different ways to get input from console. The first is probably what you meet in every introductory C++ manual. It will simply get input, skipping leading whitespace and stopping at the first whitespace character after consuming non-whitespace characters. It is dangerous since it doesn't take into account the length of the input, which could be more then the size of the buffer. The user can smash the stack if you're not careful.

The second is identical to the first, though will allocate an appropriately sized buffer for the input. Much safer.

The third will get a single line of input (including whitespace.) Note if you have used the extraction operator prior to getline, there will most likely be a newline character unconsumed in the buffer, which is why you must use invoke the ignore method. This method actually takes in the delimiter as the (optional) third argument. By default it is '\n', but you can change this to whatever you want (eg. (char)EOF)

The fourth might be handy if you ever have to store a collection of user input as whitespace-delimited words into an STL container, or even to copy files into other files, etc. Probably a bit too advanced, but I included it anyway.

Of course, the examples I've posted above only deal with strings of characters. You can use the extraction operator (>>) to parse floats, ints, and pretty much any other built-in type.

If you have a user-defined type, you have to overload the >> operator, like so:

struct foo
{
    friend istream& operator >> (istream& is, foo& f);
    int a, b, c;
};

istream& operator >> (istream& is, foo& f);
{
    is >> a >> b >> c;
    return is;
}


Consult google for more information.

Name: Anonymous 2007-10-13 18:22

Hoyl shti cna OP nto ues cin!?!?

Name: Anonymous 2007-10-13 21:46

I need to make a useful program in Lisp.

Is there any way to do this at all?




















Hahaha, just kidding. We all already know the answer: no, it isn't.

Name: Anonymous 2007-10-13 21:47

it->there

Damn, even briefly talking about that toy language caused brain damage. I can't even imagine how the people who "program" in it can function at all.

Name: Anonymous 2007-10-13 22:44

>>12
Well, first you'd have to be a useful programmer.

Name: Anonymous 2007-10-13 22:52

I'm not talking about taking user input from the console. Any half-wit who can walk and breathe at the same time can do that. I'm talking about reading something that's already been printed to the console. Anyone have ideas?

Name: Anonymous 2007-10-14 0:15

>>15
proc3ss it b4 it getz there

Name: Anonymous 2007-10-14 0:45

>>16
But how? I'd rather not get into lpszEURHandFuckLOLOLOL(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)

Name: Anonymous 2007-10-14 1:09

>>15
That's an interesting problem, but could you tell more about why you're looking to do that in the first place?

Name: lol !Ep8pui8Vw2 2007-10-14 1:18

.

Name: Anonymous 2007-10-14 1:40

http://msdn2.microsoft.com/en-us/library/ms684969.aspx

Now, what is it that you're up to?

Name: Anonymous 2007-10-14 1:48

>>18
Probably because I'm a terrible n00b and can't think of a better way to do this...

I'm trying to write a rar password cracker, and the only way I can think to do it is by using C's system function. The problem is, I need a way to figure out if the password was incorrect or not and to do that I'm trying to read what it's printed to stdout. Thus, reading in something already displayed on the console.

There's probably a terribly easy way to do this already, and I'm too much of a n00b to figure it out/realize it.

Name: Anonymous 2007-10-14 2:20

>>21
I believe this is relevant:
http://support.microsoft.com/kb/190351

Name: Anonymous 2007-10-14 4:35

>>15
Uhm, open the stdout file descriptor and use standard C facilities to read from it?

Name: Anonymous 2007-10-14 5:55

EXPERT PROGRAMMERS write and scans directly from the screen buffer

get your bullshit outta here

Name: Anonymous 2010-12-06 9:57

Back to /b/, ``GNAA Faggot''

Don't change these.
Name: Email:
Entire Thread Thread List