How do I count the number of times I tested a program?
My first attempt was this:
#include <iostream>
using namespace std;
int main()
{
static int times_tested = 0;
times_tested ++;
cout << times_tested;
system("PAUSE") ; // Yeah, I know the experts don't like "PAUSE"
but blame my // teacher
}
Obviously, it doesn't work -- the static times_tested retains its value
outside the loop but, of course, it doesn't remember the value after
the program has finished completely.
It seems that I need a sort of extremely-static designation which not
only retains the value after the loop but even after the program has
run.
Is there a way of doing this?
Thank you,
Paul Epstein 16 2145
<pa**********@a tt.net> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com How do I count the number of times I tested a program?
My first attempt was this:
#include <iostream>
using namespace std;
int main() { static int times_tested = 0;
times_tested ++;
cout << times_tested;
system("PAUSE") ; // Yeah, I know the experts don't like "PAUSE" but blame my // teacher
}
Obviously, it doesn't work -- the static times_tested retains its value outside the loop but, of course, it doesn't remember the value after the program has finished completely.
It seems that I need a sort of extremely-static designation which not only retains the value after the loop but even after the program has run.
Is there a way of doing this?
Write it to file? (Then read it and increment it next time.)
--
John Carson pa**********@at t.net wrote: How do I count the number of times I tested a program?
You can start by counting how many times you post the same message, and
working towards reducing that number...
My first attempt was this: [..] Is there a way of doing this?
What remains after your program finishes executing? Definitely not the
contents of any memory it occupies. Unless you do something platform-
specific, all memory available to you is released, so next time when you
run your program its data are the same you intended them to be:
initialised with values you specified in your source.
So, what could you use? You could use any platform-specific external
storage to keep track of those things. Create a file which will contain
a number, read it when your program starts, increment it, and write it
out to the same file. Provided that your program is the only one that is
going to change this file, you should be OK.
V
Well, yes, I can write it to file. But I don't know how to "increment
it next time". Of course, I can change the number by hand, but
computers are supposed to make such things unnecessary. I'm sure I
just misunderstand you.
Paul Epstein
<pa**********@a tt.net> wrote in message
news:11******** *************@f 14g2000cwb.goog legroups.com... Well, yes, I can write it to file. But I don't know how to "increment it next time".
Sure you do.
/* (error checking omitted) */
ifstream in("count.txt") ;
unsigned int count(0);
in >> count;
in.close;
++count;
ofstream out("count.txt" );
out << count;
out.close();
Of course, I can change the number by hand, but computers are supposed to make such things unnecessary.
Right. But for a computer to implement automation,
you need a program.
< I'm sure I just misunderstand you.
Perhaps.
-Mike
<pa**********@a tt.net> wrote in message
news:11******** *************@f 14g2000cwb.goog legroups.com... Well, yes, I can write it to file. But I don't know how to "increment it next time". Of course, I can change the number by hand, but computers are supposed to make such things unnecessary. I'm sure I just misunderstand you.
Paul Epstein
times_tested = 0;
std::ifstream DebugFileIn("de bug.dat");
if (DebugFile.is_o pen())
{
DebugFile >> times_tested;
DebugFile.close ();
}
++times_tested;
std::ofstream DebugFileOut("d ebug.dat");
if (DebugFileOut.i s_open())
{
DebugFileOut << times_tested << std::endl;
DebugFileOut.cl ose()
}
Victor Bazarov wrote: pa**********@at t.net wrote: How do I count the number of times I tested a program?
You can start by counting how many times you post the same message, and working towards reducing that number...
Victor,
This is what causes my repostings: I post a message using google.com.
It appears successful and I get the message that my post will appear
"momentaril y". Ten minutes later, the post has not appeared. After a
long enough wait, it's still not there, so I repost. It then appears
twice.
If you have an effective solution to the problem (other than "try
waiting longer"), then please share it. It's obvious (to me) that the
repost was due to some google bug (or other google problem) and not my
fault.
Paul Epstein
Victor Bazarov wrote: pa**********@at t.net wrote: How do I count the number of times I tested a program?
You can start by counting how many times you post the same message, and working towards reducing that number...
Victor,
This is what causes my repostings: I post a message using google.com.
It appears successful and I get the message that my post will appear
"momentaril y". Ten minutes later, the post has not appeared. After a
long enough wait, it's still not there, so I repost. It then appears
twice.
If you have an effective solution to the problem (other than "try
waiting longer"), then please share it. It's obvious (to me) that the
repost was due to some google bug (or other google problem) and not my
fault.
Paul Epstein
On 8 Jan 2006 04:48:29 -0800, pa**********@at t.net wrote: If you have an effective solution to the problem (other than "try waiting longer"), then please share it. It's obvious (to me) that the repost was due to some google bug (or other google problem) and not my fault. >Paul Epstein
Usenet is a system of thousands (more?) of servers that quite
literally encompass the entire earth. It takes time for your post to
propagate (travel from server to server) around the globe.
Unfortunately there is no other answer than to wait. Usenet is NOT a
real-time comm-system. Try irc for that. Metaphorically it's more like
putting a message in a bottle throwing it in the ocean current and
waiting for it to come back with a response.
If you need answers right-away this isn't the medium. If you want more
info post here and I will direct you. (I'm sorta' rusty so I would
have to look up some stuff.)
"I'm just preparing my impromptu remarks."
- Winston Churchill :-) pa**********@at t.net wrote: If you have an effective solution to the problem (other than "try waiting longer"), then please share it. It's obvious (to me) that the
The problem is: if you repost too much, people will ignore you. The obvious
solution is to not repost.
--
Salu2 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Megan |
last post by:
hi everybody-
i'm having a counting problem i hope you guys and gals could give me
some help with. i have a query that retrieves a bevy of information
from several different tables.
first let me give you a little background. this database is kind of
like a human resources database. it collects info about people, where
they work, and if they have any work-related issues where they work.
|
by: Cmorriskuerten |
last post by:
HI,
is this is this solution to test if a number is a prime number or not:
/*
* Is n a prime number?
* Return TRUE (1): n is a prime number
* Return FALSE (0): n is a *not* a prime number
*/
int is_prime_number(int n)
|
by: sathyashrayan |
last post by:
Group,
Following function will check weather a bit
is set in the given variouble x.
int bit_count(long x)
{
int n = 0;
/*
** The loop will execute once for each bit of x
set,
|
by: Matt |
last post by:
Alright, so I'm a little confused here...what exactly does this do?
I've run it and it doesn't display anything, so I've typed some things
into it, to see if it'd do something then, but to no avail. Can
somebody explain to me what this does?:
#include <stdio.h>
/* count characters in input; 2nd version */
main()
{
|
by: viuxrluxvbbc |
last post by:
Hi im trying to write a program that will read in numbers and display
them in ascending order along with a count of how many times it
repeats. i got the numerical order portion done but cant figure out the
other part. i keep on getting a wrong number
please help
#include <iostream>
using namespace std;
int main()
{
| |
by: pauldepstein |
last post by:
How do I count the number of times I tested a program?
My first attempt was this:
#include <iostream>
using namespace std;
int main()
{
|
by: tman88g |
last post by:
I've been trying to learn arrays, and I was wondering how one would go
about making a program that would take from the user as many single
digit numbers (0 - 9) as the user wants to enter, and then the program
would output the number of times each digit was inputted, (and only the
digits that were inputted). I've been toying around with this all day,
but can't seem to nail it. I've been trying to use an array as a
counter, and then putting...
|
by: bigbagy |
last post by:
Notes
The programs will be compiled and tested on the machine which runs the
Linux operating system. V3.4 of the GNU C/C++ compiler (gcc ,g++) must be used.
A significant amount coding is needed for this assignment.
1.Counting Words in C++
Problem: Write an elegant C++ program to count the number of times each word occurs
in a file. A word is defined as a sequence of characters surrounded by whitespace. Case is
not important, so...
|
by: pvinodhkumar |
last post by:
In TAOCP, Volume 3 - Sorting and Searching, Page Number -77, an
algorithm for Sorting by Comparision Counting is given. I understand
the algorithm. What I do not understand is Knuth has stated that the
running time of the program is 13N + 6A + 5B - 4;
This is the C++ snippet I am using
bool SortByComparisionCount()
{
// I use 87 instead of 087 and 61 instead of
|
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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,...
| |
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...
|
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...
|
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 project—planning, coding, testing, and deployment—without 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...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |