473,498 Members | 1,809 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Timed Function In C++

2 New Member
i need help in creating a sort of timed function. my project requires that the user must enter some words in a specified time limit ,sort of a typing speed program where the pgm count how many words you entered in given time.
So here i want a code suchn that my cin>> stops waiting for character after ,say 1 minute.please help me. please supply an example code if you can. i am aclass 11 student . this is my project(prestige issue)!!!!
thank you,
vide
Sep 5 '06 #1
2 3128
gbagur
3 New Member
You can use the clock() function.

Example:
#define <time.h>

clock_t start, elapsed_time;

main() {
start = clock();
while(1) {
--- here: your code ---
elapsed_time = (clock() - start)/CLK_TCK;
if (elapsed_time > TOPTIME) break;
}
}
Note: elapsed_time is in second.

i need help in creating a sort of timed function. my project requires that the user must enter some words in a specified time limit ,sort of a typing speed program where the pgm count how many words you entered in given time.
So here i want a code suchn that my cin>> stops waiting for character after ,say 1 minute.please help me. please supply an example code if you can. i am aclass 11 student . this is my project(prestige issue)!!!!
thank you,
vide
Sep 5 '06 #2
vide
2 New Member
You can use the clock() function.

Example:
#define <time.h>

clock_t start, elapsed_time;

main() {
start = clock();
while(1) {
--- here: your code ---
elapsed_time = (clock() - start)/CLK_TCK;
if (elapsed_time > TOPTIME) break;
}
}
Note: elapsed_time is in second.
Yes i understand your code . i tried this also .But what want to know is if suppose
i enter a code at --here; you code--
cin>>something;
and i set toptime as say 1000s
now consider the user has reached this cin>>something part and he is not getting a word to enter.So naturally he will keep on thinking what to enter for a long time (say for 10000s or 1/0s).but i want tosomehow cause the program to skip this waiting for a keybord as soon as 1000s are over and display "TIMEOUT!!!!!!" .

thank you for replying to my letter.
Hope you can resolve my problem.
thank you
vide
Sep 6 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
3904
by: Andy | last post by:
Hi Gang Is there any way with ASP that I can tell if a user session has timed out? The problem is that we have a database app where a user session may time out. After this happens the user...
2
1617
by: Javaman59 | last post by:
I have a GUI which is monitoring a real-time device. I have several timed actions, such as periodic polling of the device, and indicators which flash for a fixed period. My first implementation...
0
3776
by: Jack Wright | last post by:
Dear All, I have a web Application "http://localhost/Web/WebForm1.aspx" that calls a WebService from "http://localhost/webserviceapp/service1.asmx"...I have set the executionTimeout to 10 secs in...
5
2408
by: Jack Wright | last post by:
Dear All, I have a web Application "http://localhost/Web/WebForm1.aspx" that calls a WebService from "http://localhost/webserviceapp/service1.asmx"...I have set the executionTimeout to 10 secs in...
5
8994
by: Sachin Surana | last post by:
We use HttpWebRequest to send the request at a URL. But some times the method GetResponse throws a time out exception. But when we check the IIS logs, there is no such entry. So the request never...
6
3763
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
4
2915
by: Joe | last post by:
I'm hosting my web service on a Windows 2003 box which is remotely located. When trying to add a web reference to a C# project I get an error message 'There was an error downloading...
11
4337
by: Sumit Acharya | last post by:
I am using following script to connect to the server and i try the connection for 1000 times. Some times it succeeds for all the 1000 times,but some times it fails with error:- 10060, 'Operation...
0
1438
by: Tom | last post by:
Hi, Could someone please help me with this I am trying to do use the following code to post a form and get response but it 's keep giving me a error "The operation has timed-out." on this line...
0
2591
by: nickyeng | last post by:
Hi My program needs to connect to https server and here is my java code: URL server = null; HttpURLConnection conn = null; try{ System.setProperty("javax.net.ssl.keyStore",...
0
7005
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
5465
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
1
4916
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4595
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3096
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3087
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1424
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
659
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
293
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.