Results 1 to 11 of 11

Thread: How to use the command promp from C++?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Location
    I'm right here!
    Posts
    849

    Question How to use the command promp from C++?

    Hello!!!

    I want to execute a command from c++ as if it was executed from the
    command prompt...

    how can I do that?

    thanks!!

    Dekel C.

  2. #2
    Addicted Member SpS's Avatar
    Join Date
    Jul 2005
    Posts
    201

    Re: How to use the command promp from C++?

    try something like this
    Code:
    system("start notepad");
    or
    Code:
    system("notepad");
    #Appreciate others by rating good posts !!

    #The Software Peter Principle is in operation when unwise developers "improve" and "generalize" the software until they themselves can no longer understand it, then the project slowly dies.

    #People who are still ignorant of their ignorance are dangerous.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Location
    I'm right here!
    Posts
    849

    Re: How to use the command promp from C++?

    is that for visual c++ .Net or for native c++?

    Dekel C.

  4. #4
    Addicted Member SpS's Avatar
    Join Date
    Jul 2005
    Posts
    201

    Re: How to use the command promp from C++?

    I tired this in VC6.0...from next time do mention your requirements completely
    #Appreciate others by rating good posts !!

    #The Software Peter Principle is in operation when unwise developers "improve" and "generalize" the software until they themselves can no longer understand it, then the project slowly dies.

    #People who are still ignorant of their ignorance are dangerous.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Location
    I'm right here!
    Posts
    849

    Re: How to use the command promp from C++?

    do I need to include any class to use this command?
    because my sytem doesn't recognise it...

    Last edited by dekelc; Jan 9th, 2006 at 12:51 PM.
    Dekel C.

  6. #6
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403

    Re: How to use the command promp from C++?

    For C++, include <cstdlib> and use std::system().
    For C, include <stdlib.h> and use system().
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  7. #7
    Lively Member
    Join Date
    Dec 2005
    Posts
    68

    Re: How to use the command promp from C++?

    Just curious what does the system function do generally?

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: How to use the command promp from C++?

    It passes the string you give it to "the system shell" (whatever that is) for execution.
    In Linux, this usually means the Bourne Shell, /bin/sh. In Windows, it means cmd.exe.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  9. #9
    Lively Member
    Join Date
    Dec 2005
    Posts
    68

    Re: How to use the command promp from C++?

    Quote Originally Posted by CornedBee
    It passes the string you give it to "the system shell" (whatever that is) for execution.
    In Linux, this usually means the Bourne Shell, /bin/sh. In Windows, it means cmd.exe.
    ok,I understood that partially,does it mean that it executes whatever file or string I put in it?

  10. #10
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: How to use the command promp from C++?

    No. "It passes it to the shell" means exactly that.
    If you want to know what it does, select Start->Run, type "cmd", and in the window that opens, type whatever you want to pass to system().
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  11. #11
    Addicted Member SpS's Avatar
    Join Date
    Jul 2005
    Posts
    201

    Re: How to use the command promp from C++?

    #Appreciate others by rating good posts !!

    #The Software Peter Principle is in operation when unwise developers "improve" and "generalize" the software until they themselves can no longer understand it, then the project slowly dies.

    #People who are still ignorant of their ignorance are dangerous.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width