A small issue.

This is a discussion on A small issue. within the C++ Programming forums, part of the General Programming Boards category; Hey. What is the command for delay / held? My program prints a text in a window and then straight ...

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    23

    A small issue.

    Hey. What is the command for delay / held?

    My program prints a text in a window and then straight after the text it goes on as programmed. So how do I make a 3 sec delay between the printed text and the next action of the program? (so the text will appear and show for 3 secs, and then the program continues as programmed)?

    Thanks,
    -Overwhelm.
    Last edited by Overwhelm; 01-15-2005 at 11:59 PM.

  2. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    You might try one of the functions listed here: http://faq.cprogramming.com/cgi-bin/...&id=1043284392

    But replace the first line with:
    Code:
    #include <ctime>
    using namespace std;
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  3. #3
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903

    #include<windows.h>

    You can use the sleep( ) function.. which takes the number of milliseconds as an argument.
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    23
    Alright. So to the next command then. What is the command for deleting a specific folder? (Do not misunderstand me though, I intend to make no harm. Only to specify folders such as C:/Windows/Temporary Internet Files, Cookies, Page History etc.)

    So...

    void delete(); ... or something?

  5. #5
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    Code:
    #include<cstdlib>
    
    system("delete C:\\Windows\\Temporary Internet Files\\Cookies\\file.*");

    or
    Code:
    #include<cstdio>
    
    remove("delete C:\\Windows\\Temporary Internet Files\\Cookies\\file.*");
    or an API call
    Code:
    #include<windows.h>
    
    DeleteFile("delete C:\\Windows\\Temporary Internet Files\\Cookies\\file.*");
    Last edited by The Brain; 01-16-2005 at 01:12 AM.
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  6. #6
    Registered User
    Join Date
    Jan 2005
    Posts
    23
    Quote Originally Posted by The Brain
    Code:
    #include<cstdlib>
    
    system("delete C:\\Windows\\Temporary Internet Files");

    or an API call
    Code:
    #include<windows.h>
    
    DeleteFile("file.exe");

    or
    Code:
    #include<cstdio>
    
    remove("file.txt");
    -- First one is compiled but doesn't work? -- Why is the two \ instead of one?

    -- Second I do not understand. Where is the path? -- If no path, does it delete all files named after what reads between the " "?

    -- Third, same as second.


  7. #7
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    I do not understand. Where is the path?
    I edited the post to put the paths in for you. (I was kinda hoping you would pick up on what was going on)

    Use a double \\ inside whilst inside quotations because the backslash is used to signal an escape character:
    \n, \t, \a, \" for example.
    Last edited by The Brain; 01-16-2005 at 01:07 AM.
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  8. #8
    Registered User
    Join Date
    Jan 2005
    Posts
    23
    Code:
    #include <iostream>
    #include <stdlib.h>
    #include <cstdio>
    
    using namespace std;
    
    int main(int argc, char *argv[])
    {
    
    remove("C:\\Windows\\Temporary Internet Files");	
      
      return 0;
    }
    -- The code I made. Doesn't work. -- Using Win98, makes any difference?

  9. #9
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    I think what you want to do is to delete an entire directory..

    Check out this or this.


    Also, every computer is different. Make sure your paths are correct for your computer before using them. (Go to "My Computer" and keep track of the path you take to reach your destination file or folder)
    Last edited by The Brain; 01-16-2005 at 01:33 AM.
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  10. #10
    Registered User
    Join Date
    Jan 2005
    Posts
    23
    My IQ isn't high enough to understand that "this" -link of yours. Isn't there just a basic easy simple code which deletes a specific folder without asking anything. Just execute the file and folders deleted. :P

  11. #11
    Registered User
    Join Date
    Jan 2005
    Posts
    23
    Anyone? Still the problem stands. Just a basic, easy, simple, working code which deletes a specific folder (Like C:/Windows/Temporary Internet Files/) when program executed.

  12. #12
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    Don't bump your threads.

    And at the end of that link given to you by The Brain, Thantos makes a good suggestion. If you're using Win98 and you promise us that this program will never be used by anyone else (system() has major drawbacks when there are unknowns such as OS, etc...), thenyou can just use
    Code:
    #include <cstdio>
    system("deltree C:\\Windows\\Temporary Internet Files");
    Just make sure that the path is right.

  13. #13
    UT2004 Addict Kleid-0's Avatar
    Join Date
    Dec 2004
    Posts
    656
    Open up the command prompt and type in something like:
    Code:
    del -h
    or
    del -help
    Then cd into a directory with directories that you wouldn't mind deleting, and do something like this:
    Code:
    cd C:/mydirectory/
    del -R -Q ./
    This will remove all of the files in that directory.
    -R Recusively
    -Q Quietly
    Now that you have tested this MS only tool, try something like this in a program:
    Code:
    system("del -Q -R 'C:/Windows/Temporary Internet Files'")
    But watch out my brother! I've deleted parts of my C drive with that tool! Be extra careful, demons are everywhere!

    And be sure to check that folder exists!

  14. #14
    Registered User
    Join Date
    Jan 2005
    Posts
    23
    Code:
    #include <stdio.h>
    #include <cstdio>
    #include <conio.c>
    #include <iostream>
    #include <cstdlib>
     
    using namespace std;
    
    
    int main(int argc, char *argv[])
    {
    
        system("del C:\\WINDOWS\\Temp\\Cookies");
    
        cout << "Cookies deleted." << endl;
    
      getche();
      return 0;
    }
    -- So here's the code that works, but it asks "Are you sure? Y/N" -- How to bypass this?

  15. #15
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    A quick and dirty solution would be to pipe the output to a file
    Code:
    system("del C:\\WINDOWS\\Temp\\Cookies > file.txt");
    At least I think that's how you do it in MS systems - don't use this until someone else confirms it. Basically what that does is tell the computer that anything del.exe sends to stdout (the standard output stream) should be redirected away from the screen and into a file. In the real world we would've started with a better solution than system anyway, and this method makes it even dirtier - so now you have even more reason to keep this program for personal use only.

Page 1 of 3 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. float calculation issue
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 05-26-2008, 05:56 AM
  2. Small Logic Issue
    By Flakster in forum C++ Programming
    Replies: 5
    Last Post: 05-29-2006, 03:40 PM
  3. Newb With Small Pointer Issue
    By G-Prime in forum C Programming
    Replies: 7
    Last Post: 09-06-2004, 05:09 PM
  4. help with small program. array issue
    By InvariantLoop in forum C++ Programming
    Replies: 2
    Last Post: 04-09-2004, 01:26 PM
  5. Small issue with system()
    By Metal Man in forum C++ Programming
    Replies: 8
    Last Post: 10-21-2003, 02:33 PM

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