473,624 Members | 2,252 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(prestig e issue)!!!!
thank you,
vide
Sep 5 '06 #1
2 3142
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(prestig e 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
3917
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 may try to save the data that is on there screen (without knowing they've timed out). I think what happens then (after the save) is that we get zero's in some of the fields in the database because the session has timed out.
2
1627
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 of this was to replicate the way I have seen this done before - have one central timed method, which is on a timer tick, and use time variables to keep track of when events are due. I have now realized that I can avoid the timer method, and time...
0
3811
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 Web.Config where my WebService is installed. <httpRuntime executionTimeout="10" appRequestQueueLimit="2" /> When I call a method "TestPlan" which takes more than 10 secs my web Page gets the following error:
5
2415
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 Web.Config where my WebService is installed. <httpRuntime executionTimeout="10" appRequestQueueLimit="2" /> When I call a method "TestPlan" which takes more than 10 secs my web Page gets the following error:
5
9021
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 reached the server but the client is getting a time out exception. What could be the possible reasons? Confirmed that the request does not get lost in the network.
6
3782
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 one day): \\FFDS24\ASP.NET Applications(_LM_W3SVC_1_Root_ATV2004)\Errors During Execution: 7 \\FFDS24\ASP.NET Apps v1.1.4322(_LM_W3SVC_1_Root_ATV2004)\Compilations
4
2927
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 'http://mydomain.com:port/webservice.asmx' The operation has timed-out (I've tried with and without using a separate port for the service) The weird thing is the page does show up on the left side of the screen listing the available methods but the Add...
11
4363
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 timed out'. When it fails with the abover error, it seems timed out time is 20 seconds. Is there a way I can increase the timedout time for FTP? from ftplib import FTP import time import sys
0
1447
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 oRespons = CType(oRequest.GetResponse(), HttpWebResponse) I have to us Unicode Encoding so it knows national charactor.
0
2607
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", "eejis.jks"); System.setProperty("javax.net.ssl.keyStorePassword", "ee123");
0
8242
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8177
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8681
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8629
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8488
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7170
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, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
2611
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 we have to send another system
2
1488
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.