System();

This is a discussion on System(); within the C++ Programming forums, part of the General Programming Boards category; I'm starting this post soo people can write all the system(); codes they know. i already know : system("pause"); -- ...

  1. #1
    Dragoon Lover wyvern's Avatar
    Join Date
    Jul 2005
    Location
    dragooncity
    Posts
    28

    System();

    I'm starting this post soo people can write all the system(); codes they know.

    i already know :

    system("pause"); -- holds program
    system("cls"); -- cleans screen
    system("start") -- opens a msdos window

    i know i could just open cmdline and type help but some comands in held dont work on system(); code (like exit comand)
    soo people please type here any system codes know.

  2. #2
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    don't use system().

    for a list, open your start menu, click run, type "cmd" and type "help". anything you can type on the command line can be put into system().

    but don't use system(). It opens your program up to potential security flaws and makes your code non-portable... for example, try using the following code:
    Code:
    #include<cstdlib>
    
    int main()
    {
    	system("clear");
    	system("cal");
    	return 0;
    }
    on my system, it prints:
    Code:
         August 2005
    Su Mo Tu We Th Fr Sa
        1  2  3  4  5  6
     7  8  9 10 11 12 13
    14 15 16 17 18 19 20
    21 22 23 24 25 26 27
    28 29 30 31
    
    jshao@MCP ~/Programming/C++ $
    what does it do on yours?
    Last edited by major_small; 08-22-2005 at 06:48 AM. Reason: lala
    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

  3. #3
    Dragoon Lover wyvern's Avatar
    Join Date
    Jul 2005
    Location
    dragooncity
    Posts
    28
    please explain better

  4. #4
    ... arjunajay's Avatar
    Join Date
    May 2005
    Posts
    203
    I believe sytem is OS specific.
    ie, the strings you pass are actually commands you give to the OS and obviously differ from OS to OS.

  5. #5
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    the system() command is standard, however what you pass to it is not. like arjunajay just said, the string (char*, actually) that you pass into system() is just basically passed on to the Operating System. when you write system("cls");, it's essentially the same as writing cls and hitting enter at the command prompt.

    what I meant by my example is that there is no "list" of commands. it differs from system to system. What you can use depends on what's in your path enviroment variable. if you want a complete list on windows, type echo %PATH% and press enter. it should list a few directories. now you can type dir <pathname> (if there's a recursive version of this, use it) for each pathname listed by the first step. everything in that list can be used in the system() command. for example, I set up my windows box so that I could call GCC from the command line, so I could write system("g++ test.cpp -Wall -W -ansi -pedantic -o test.exe"); and it would work. it would not work on your system.

    my point was that I'm using linux right now, and the commands I used above clears the screen and print a text calandar for this month to the screen, then exit. In windows, nothing should happen. you might get errors on the console, but that's about it.

    basically here's my point: DON'T USE SYSTEM().
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File System Implementation
    By dodgeviper in forum C Programming
    Replies: 9
    Last Post: 11-16-2007, 12:04 PM
  2. Using system icons
    By @nthony in forum Windows Programming
    Replies: 1
    Last Post: 01-13-2007, 06:56 PM
  3. Linux database system needed
    By BobS0327 in forum Tech Board
    Replies: 7
    Last Post: 06-11-2006, 03:56 PM
  4. BIOS system and memory allocation problem
    By beely in forum Tech Board
    Replies: 9
    Last Post: 11-25-2003, 06:12 AM
  5. Number system base M, print numbers N digits wide...
    By biterman in forum C Programming
    Replies: 12
    Last Post: 11-19-2001, 03:31 AM

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