Thread: ystem commands for consoles

  1. #1
    Emotionally Unstable DarkViper's Avatar
    Join Date
    Oct 2002
    Posts
    343

    ystem commands for consoles

    ok, i know system("pause") when you #include <stdlib.h>. but what is the command for makeing the system wait for say... 2 seconds?

    i think its system("sleep") but i dont know how to set the time for it.

    but this is what i need, i need it to look like its processing something when really its doing nothing and quickly executes a block of code like 2 seconds later.

    there is no source code or anything to display, i need the system command, is all.
    ~DJ DarkViper signing out
    ----------------------------------------
    My Site:
    Black Jaguar Studios

    Languages:
    Fluent English, Starter German, HTML, Javascript, Actionscript, Intermediate PHP

    Verteran Despiser of: ASP, Java, BASIC, Pascal, Cobalt

  2. #2
    Bios Raider biosninja's Avatar
    Join Date
    Jul 2002
    Location
    South Africa
    Posts
    765
    Why not write your own delay function like me?

    Code:
    void delays(unsigned msecs)
    {
        long ticks;
    
        ticks = biostime(0,0);
        while ((biostime(0,0)-ticks)/CLK_TCK*1000 < msecs)
        {
        }
    }
    or just use the delay (not sure in witch header file)

  3. #3
    Emotionally Unstable DarkViper's Avatar
    Join Date
    Oct 2002
    Posts
    343
    hehehe, sounds good, thanx, ill use that every once i a while when i need it. thanx again!
    ~DJ DarkViper signing out
    ----------------------------------------
    My Site:
    Black Jaguar Studios

    Languages:
    Fluent English, Starter German, HTML, Javascript, Actionscript, Intermediate PHP

    Verteran Despiser of: ASP, Java, BASIC, Pascal, Cobalt

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    And windows machines have:
    Sleep(millisec);

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    On unix you may have sleep() in unistd.h

    Here's some more portable code:
    Code:
    #include <time.h>
    
    void sleep_seconds ( long seconds ) {
      clock_t limit, now = clock();
      limit = now + seconds * CLOCKS_PER_SEC;
      while ( limit > now )
        now = clock();
    }
    void sleep_ticks ( long ticks ) {
      clock_t limit, now = clock();
      limit = now + ticks;
      while ( limit > now )
        now = clock();
    }
    But remember, high speed looping often causes high CPU usage, which is a good reason for finding your compiler/OS's sleep function.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  6. #6
    Emotionally Unstable DarkViper's Avatar
    Join Date
    Oct 2002
    Posts
    343
    LOL! i have windows 98 adn i use bloodshed dev C++ latest beta version.

    ive been using it since 3 came out. i like it better than MSVC++
    ~DJ DarkViper signing out
    ----------------------------------------
    My Site:
    Black Jaguar Studios

    Languages:
    Fluent English, Starter German, HTML, Javascript, Actionscript, Intermediate PHP

    Verteran Despiser of: ASP, Java, BASIC, Pascal, Cobalt

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Get user commands from text file.
    By Ironic in forum C Programming
    Replies: 4
    Last Post: 12-08-2008, 11:38 PM
  2. Executing DOS commands from inside an image
    By Moony in forum C Programming
    Replies: 6
    Last Post: 03-16-2008, 12:40 PM
  3. Replies: 2
    Last Post: 07-27-2007, 12:48 PM
  4. Executing system commands cross platform
    By markucd in forum C++ Programming
    Replies: 6
    Last Post: 11-04-2005, 08:56 AM
  5. Bluetooth Dial-up network profile with AT commands
    By BrownB in forum Networking/Device Communication
    Replies: 0
    Last Post: 06-29-2005, 02:47 AM