petteyg 27 Newbie Poster

Look at cURL. You'll need the first PHP script to be running on a web server.

If you're not running a server, look at $argv and/or getopt.

petteyg 27 Newbie Poster

installed Wine and tried running Windows XP setup

Wine is for running specific programs, not installing Windows. If there's a program you're trying to run, you just do something like "wine steaminstaller.exe" (where steaminstaller.exe can be any .exe file). You would use winesetup to configure wine (select sound options, add drive mappings, etc.), and you can use winetricks to install stuff like DirectX, IE, VS runtimes, etc. Wine can't run everything, though.

If you want to have a complete Windows desktop that will run everything, you need VMWare Workstation, VirtualBox, Qemu, or some other virtual machine. VirtualBox is my favorite (free and requires barely any configuration). Some colleges provide access to a free copy of VMWare Workstation.

If you're actually trying to re-install Windows, you shouldn't be booted into Linux in the first place. Boot from the Windows disc.

petteyg 27 Newbie Poster

Got a dedicated server that doesn't have 24/7 load? Put Folding@Home on it so this might be curable in the future. Didn't know Dave, but I survived a brain tumor myself and had a close friend die from one. R.I.P.

petteyg 27 Newbie Poster

setvbuf does not produce the same result. It doesn't remove the need hit enter/return. Suppose I'll deal with ncurses.

Ancient Dragon commented: you are right about setvbuf. +27
petteyg 27 Newbie Poster

Right right, I see how setw() works now, I feel as though there should be an easier way to align a table though, since there could possibly be unknown string lengths given after a call to setw()...

Iterate through your strings, find the longest length, store it, and use that for setw(). Or, truncate output to a set number of characters.

petteyg 27 Newbie Poster
cout << i++ << ":" << setw(5) << "Open the program." << endl << i++ << ":" << setw(5) << "Click \"File\" and then\"New\"." << endl;

Default alignment is right (probably locale-based, but I've never used any RTL locale, so don't know), using char(32) for fill. If the output is longer than 5 characters, setw(5) isn't going to do anything. It applies only to what is immediately after it. Try instead:

cout << left;
cout << i++ << setw(5) << ":" << "Open the program." << endl;
cout << i++ << setw(5) << ":" << "Click \"File\" and then\"New\"." << endl;

You'll have to cout << right or reset iosflags if you later want to setw() and have output right-aligned.

@Software guy: An arbitrarily sized setw() on every line is a horrible way to go about formatting output.

petteyg 27 Newbie Poster

code from this blog

int kbhit()
{
    struct timeval tv;
    fd_set fds;
    tv.tv_sec = 0;
    tv.tv_usec = 0;
    FD_ZERO(&fds);
    FD_SET(STDIN_FILENO, &fds); //STDIN_FILENO is 0
    select(STDIN_FILENO+1, &fds, NULL, NULL, &tv);
    return FD_ISSET(STDIN_FILENO, &fds);
}
void nonblock(int state)
{
    struct termios ttystate;

    //get the terminal state
    tcgetattr(STDIN_FILENO, &ttystate);

    if (state==NB_ENABLE)
    {
        //turn off canonical mode
        ttystate.c_lflag &= ~ICANON;
        //minimum of number input read.
        ttystate.c_cc[VMIN] = 1;
    }
    else if (state==NB_DISABLE)
    {
        //turn on canonical mode
        ttystate.c_lflag |= ICANON;
    }
    //set the terminal attributes.
    tcsetattr(STDIN_FILENO, TCSANOW, &ttystate);

}
int main()
{
    char c;
    int i=0;

    nonblock(NB_ENABLE);
    while(!i)
    {
        usleep(1);
        i=kbhit();
        if (i!=0)
        {
            c=fgetc(stdin);
            if (c=='q')
                i=1;
            else
                i=0;
        }

        fprintf(stderr,"%d ",i);
    }
    printf("\n you hit %c. \n",c);
    nonblock(NB_DISABLE);

    return 0;
}

This is the only example of "non-enter" input I've been able to find. Is this code portable between operating systems and compilers? Any reason why it wouldn't be a good idea to use?