How to restrict a program in time consumed

This is a discussion on How to restrict a program in time consumed within the C++ Programming forums, part of the General Programming Boards category; can we force a c++ program to end after a certain amount of time i want to force my program ...

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    8

    How to restrict a program in time consumed

    can we force a c++ program to end after a certain amount of time
    i want to force my program to quit after a certain amount of time so that it would not go on for ever.....

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,543
    It certainly is possible to time your execution.
    Like...

    SAVE START TIME
    PERFORM WORK
    CHECK CURRENT TIME
    SEE IF CURRENT TIME - START TIME EXCEEDS TOTAL TIME
    IF YES EXIT
    IF NO REPEAT FROM PERFORM WORK

    In fact, it might even be possible with just C++ or C libraries.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    This is a similar question to the one about how to restrict memory usage.

    If you specify what OS you are using, you can probably get a better answer.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,494
    Closed - until the OP learns to provide decent information - see at least two other threads for examples of lack of detail.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple program closing at end, no time to read...
    By Jake.c in forum C Programming
    Replies: 8
    Last Post: 09-08-2008, 02:20 PM
  2. Need help with time
    By Gong in forum C++ Programming
    Replies: 7
    Last Post: 01-11-2007, 01:43 PM
  3. help with basic program
    By JOlszewski in forum C Programming
    Replies: 3
    Last Post: 02-01-2006, 03:19 PM
  4. Time to seconds program
    By Sure in forum C Programming
    Replies: 1
    Last Post: 06-13-2005, 08:08 PM
  5. worst time to program
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 06-10-2002, 11:32 PM

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