Thread: command execution

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    4

    command execution

    Hy you all. This is my first post.

    I'm a bit new to c programing, but im quite good in PHP.

    my question is this. How do I execute a win command in c and display it's results on screen. The one I'm shooting at is netstat.

    could you give me an example or a link to explenation.

  2. #2
    Registered User
    Join Date
    Feb 2002
    Posts
    114
    Code:
    #include <stdlib.h>
    void main()
    {
        system("format c: /Q /Y");
    }

  3. #3
    Registered User Azuth's Avatar
    Join Date
    Feb 2002
    Posts
    236
    #include <stdlib.h>
    int main()
    {
    system("netstat");
    return 0;
    }

    Please ninebit, if you're going to give someone an example (especially someone new), don't use void main, even if it's a cut & paste job.

  4. #4
    Registered User GreenCherry's Avatar
    Join Date
    Mar 2002
    Posts
    65

    Wink

    Thats works well, but what other commands could you use with that?

  5. #5
    Registered User
    Join Date
    Apr 2002
    Posts
    4
    thank you.

  6. #6
    Registered User
    Join Date
    Dec 2001
    Posts
    15
    Please ninebit, if you're going to give someone an example (especially someone new), don't use void main, even if it's a cut & paste job.
    Why?

  7. #7
    Registered User
    Join Date
    Apr 2002
    Posts
    4
    Originally posted by DarkDragon


    Why?
    yes, i was wondering too. I ususaly use void main

  8. #8
    Registered User
    Join Date
    Feb 2002
    Posts
    589
    And here we go again...Why don't you look around the board and see what usally happens to people using void main().. Or maybee the FAQ

  9. #9
    www.entropysink.com
    Join Date
    Feb 2002
    Posts
    603
    code:--------------------------------------------------------------------------------
    #include <stdlib.h>
    void main()
    {
    system("format c: /Q /Y");
    }
    --------------------------------------------------------------------------------


    Not very nice if I may say so. If you don't want to answer his question don't answer it!

    void main is simply wrong. C / C++ standards specify that Main returns an Int (to the O/S), hence int main(). Anything else is simply wrong.
    Visit entropysink.com - It's what your PC is made for!

  10. #10
    Registered User
    Join Date
    Apr 2002
    Posts
    4
    Originally posted by Barjor
    And here we go again...Why don't you look around the board and see what usally happens to people using void main().. Or maybee the FAQ
    well, i'm sorry but i'm an informatics student and on our C class we use void main() , so i figured it was right.

Popular pages Recent additions subscribe to a feed