Replication of a DOS window?

This is a discussion on Replication of a DOS window? within the C++ Programming forums, part of the General Programming Boards category; I know this can be done, I've seen the code before... but I wanted to make my own without looking ...

  1. #1
    C++ beginner
    Join Date
    Jun 2004
    Posts
    66

    Replication of a DOS window?

    I know this can be done, I've seen the code before... but I wanted to make my own without looking at anyone elses... you know?

    I plan on taking inoput from the user and storing it into a string... then calling the system command with the string that holds the command...

    Following? How is this done?
    Oh my goodness.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,671
    Take input from the user and store it in a string. Call the system() function with that string.

    Nice signature.

    Welcome to the boards.

    gg

  3. #3
    C++ beginner
    Join Date
    Jun 2004
    Posts
    66
    Is there any specific type of string to use? Like a .. c string? maybe?
    Oh my goodness.

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,671
    Obtain a string from the user (C++)

    Other parts of the FAQ may help as well.

    gg

  5. #5
    C++ beginner
    Join Date
    Jun 2004
    Posts
    66
    so it'd be like this:

    Code:
    #include <iostream> 
    #include <string> 
    using namespace std;
    
    int main()
    {
        string line;
        
        getline (cin, line );
        system( << line << );
     
    }
    or am I way off?
    Oh my goodness.

  6. #6
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,088
    Close, but not quite (did you compile it and find out?) Normally you would just put line in the function call to pass it the string like this:

    func(line);

    With the system function, you can't pass a string variable, so you must do this:

    system(line.c_str());

    which passes a C-style string to the function. Also, you'll need to include the appropriate header to use the system function. In this case, that's <cstdlib>.

  7. #7
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    here's another part of the FAQ that may be useful: Run a program from within a program

    just keep in mind that all somebody has to do is replace a program with their own and they can make your program run malicious code without even knowing it...
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  8. #8
    C++ beginner
    Join Date
    Jun 2004
    Posts
    66
    Thanks for the help guys
    Oh my goodness.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Just starting Windows Programming, School me!
    By Shamino in forum Windows Programming
    Replies: 17
    Last Post: 02-22-2008, 07:14 AM
  2. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  3. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 10:06 AM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  5. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21