Im writting a very simple command-line. I want the > Charecter to come up every time a command ha finished what it's doing (easy) AND when the user presses enter with nothing on it. For example ($ is currssor) I want this:

>
>$

Not this:

>
$

How would I go about doing that?

I am not sure I understand. Why can't you just do this:

cout<<"<"<<"$"<<endl;

If you are on unix (Mac/BSD/Linux) go to terminal, on windows go to Command Prompt. Press Enter A few Times, look at what happens (I dont know what words to use), that's what I want (but with >).

couldn't you go kbhit_()??

Im writting a very simple command-line. I want the > Charecter to come up every time a command ha finished what it's doing (easy) AND when the user presses enter with nothing on it.

I guess it completely depends on your design of how your input works.

What I'd do is

  1. Output the prompt ">".
  2. Read an entire line.
  3. I'd then parse the command entered.
  4. Then execute the command if there is one.
  5. When done with all that, loop back to #1.

Here is a simple function that uses just iostream functionality:

string getCommandLine(string prompt)
{
    cout<<prompt<<" ";
    string ret;
    cin>>ret;
    return ret;
}

Is that what you are looking for?

Labdabeta, that doesnt account for when the user doesn't type anything and just presses enter.
WaltP, I'm... Not Good at text/string manipulation, if you could help great!
Right no it's:

do{
cout<<"> ";
cin>>command;
//Test For Valid Comman and other stuff
while(0==0);

Zvjezdan23, what's that?

Look again at what I posted. cin>>command; does not read an entire line.

Look again at what I posted. cin>>command; does not read an entire line.

TRY cin.getline()

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.