473,394 Members | 1,640 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Counting the number of times I've tested a program

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

Jan 6 '06 #1
16 2133
<pa**********@att.net> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.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
Jan 6 '06 #2
pa**********@att.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
Jan 6 '06 #3
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

Jan 7 '06 #4
<pa**********@att.net> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.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
Jan 7 '06 #5
<pa**********@att.net> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.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("debug.dat");
if (DebugFile.is_open())
{
DebugFile >> times_tested;
DebugFile.close();
}

++times_tested;

std::ofstream DebugFileOut("debug.dat");
if (DebugFileOut.is_open())
{
DebugFileOut << times_tested << std::endl;
DebugFileOut.close()
}
Jan 8 '06 #6

Victor Bazarov wrote:
pa**********@att.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
"momentarily". 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

Jan 9 '06 #7

Victor Bazarov wrote:
pa**********@att.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
"momentarily". 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

Jan 9 '06 #8
On 8 Jan 2006 04:48:29 -0800, pa**********@att.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 :-)
Jan 9 '06 #9
pa**********@att.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
Jan 9 '06 #10
Julián Albo wrote:
pa**********@att.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.

This was another big Google screw-up. The people posting had no way of
knowing what was going on. Posts were delayed many hours in some cases,
in others bogus server error messages were generated making the users
think the post hadn't gone out.

As someone said elsewhere, if Microsoft was running this, and as badly
as this, people on usenet would be demanding a march on headquarters
with torches and pitchforks.


Brian

Jan 9 '06 #11
Default User 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.

This was another big Google screw-up. The people posting had no way of
knowing what was going on. Posts were delayed many hours in some cases,
in others bogus server error messages were generated making the users
think the post hadn't gone out.


You (or the OP) can blame google if you want, but the result is the same.
People do multipost, not google. If you are impatient because of google
groups delays, the solution is to not use google groups. And remember,
impatience the Dark Side is.
As someone said elsewhere, if Microsoft was running this, and as badly
as this, people on usenet would be demanding a march on headquarters
with torches and pitchforks.


You can demand it if you want.

--
Salu2
Jan 9 '06 #12
Julián Albo wrote:
Default User wrote:

This was another big Google screw-up. The people posting had no way
of knowing what was going on. Posts were delayed many hours in some
cases, in others bogus server error messages were generated making
the users think the post hadn't gone out.


You (or the OP) can blame google if you want, but the result is the
same. People do multipost, not google. If you are impatient because
of google groups delays, the solution is to not use google groups.
And remember, impatience the Dark Side is.


It wasn't just the impatience, it was the messages indicating that the
posts weren't sent.

However, if I posted from NIN as usual, and the messages didn't show up
anywhere for hours, I'd be tempted to do so reposting as well.

The fault was with Google, primarily.
As someone said elsewhere, if Microsoft was running this, and as
badly as this, people on usenet would be demanding a march on
headquarters with torches and pitchforks.


You can demand it if you want.


The point was that people seem to give Google a lot more slack than
deserved in these situations.

Brian

Jan 10 '06 #13
Default User wrote:
> As someone said elsewhere, if Microsoft was running this, and as
> badly as this, people on usenet would be demanding a march on
> headquarters with torches and pitchforks.

You can demand it if you want.

The point was that people seem to give Google a lot more slack than
deserved in these situations.


Sue people.

--
Salu2
Jan 10 '06 #14

Default User wrote:
Julián Albo wrote:
pa**********@att.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.

This was another big Google screw-up. The people posting had no way of
knowing what was going on. Posts were delayed many hours in some cases,
in others bogus server error messages were generated making the users
think the post hadn't gone out.


For a few days recently I believe many of my post actually never did
get out.

Another problem I have been running into recently is that "Post
message" will hang the first time. After 5 minutes of waiting for
google.com to respond I press stop and try again just like anyone would
when a news client goes into infinite wait. This has resulted in a
second post from time to time.

What it boils down to is a broken nntp client that a whole lot of
people happen to use. To those that feel they just have to complain
and yell at people: shit happens; live with it.

Jan 10 '06 #15
On 10 Jan 2006 15:08:26 -0800, ro**********@gmail.com wrote:
What it boils down to is a broken nntp client that a whole lot of
people happen to use. To those that feel they just have to complain
and yell at people: shit happens; live with it.


Do you? It's free. It works. Free Agent. Perhaps?

http://www.forteinc.com/agent/download.php

"Without a measureless and perpetual uncertainty,
the drama of human life would be destroyed."
- Winston Churchill
Jan 10 '06 #16
ro**********@gmail.com wrote:

What it boils down to is a broken nntp client that a whole lot of
people happen to use. To those that feel they just have to complain
and yell at people: shit happens; live with it.

I don't much blame the users, as I said I was one for several months
last year. It became pretty obvious something bad was happening when
there were lots of multiple posts in various groups.

Google needs to be more proactive in recognizing that there are
problems and letting their users know. A simple message about delays
and server hangups, with a notice not to repost, would have helped.

Brian

--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
Jan 10 '06 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
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...
32
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...
7
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,
5
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...
4
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...
13
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() {
9
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...
4
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...
0
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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
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...

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.