|
I am using Visual c++ NET 2005.
How can I get the system date ?
|
|
|
|
|
There is DateTime class in .Net Framework.
|
|
|
|
|
Use DateTime class to get the system date. The Now method returns the current system time.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
|
I want Copying the Data from an ASCII Text File on a PC Back to an Operating System Spooled File for Iseries don't use ftp.
thanks very much.
|
|
|
|
|
It is rude to cross post.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I'm trying to write a function but I believe my parameters are wrong.
void printWinner(matchWon, gameWon, gameLost)
{
cout << endl << endl
<< "Player Matches Games Games" << endl;
<< " Won Won Lost " << endl;
<< "------ ------- ----- -----" << endl;
<< " A " << matchWonA << " " << gameWonA
<< " " << gameLostA << endl;
<< " B " << matchWonB << " " << gameWonB
<< " " << gameLostB << endl;
<< " C " << matchWonC << " " << gameWonC
<< " " << gameLostC << endl;
This being my code, I was wondering if I should give a function to each of my players (A, B, C).
So, void printAScore (matchWonA, gameWonA, gameLostA)
void printBScore (matchWonB, gameWonB, gameLostB)
and same thing with C.
What is the most efficient way of doing this?
|
|
|
|
|
kclkl18 wrote: What is the most efficient way of doing this?
You don't show valid C++ code, and you're wondering about efficiency?
Please post on the correct board:
Visual C++/MFC Board[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
kclkl18 wrote:
What is the most efficient way of doing this?
Reading a good C++ tutorial.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Any ideas why the following code runs faster (19 vs 37 msec in the first test) with /clr flag on? No clr is used in the code at all!
#include "stdafx.h"
class myClass
{
};
int main()
{
clock_t start;
const int COUNT = 100000;
myClass* objects[COUNT];
start = clock();
for (int i = 0; i < COUNT; i++) {
objects[i] = new myClass();
delete objects[i];
}
printf("Native with delete: %f\n", (double)(clock() - start));
start = clock();
for (int i = 0; i < COUNT; i++){
objects[i] = new myClass();
}
clock_t start2 = clock();
for (int i = 0; i < COUNT; i++){
delete objects[i];
}
printf("Native without delete: %f\n", (double)(start2 - start));
printf("Deletion: %f\n", (double)(clock() - start2));
printf("Total: %f\n", (double)(clock() - start));
}
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
Because managed code ROCKS!
But seriously...
gajatko wrote: 19 vs 37 msec
It's unlikely your tick count has a resolution better that 19ms. That
looks suspiciously like the difference between a single tick.
Maybe try timing something that takes a few seconds or use
the performance counter for timing.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
With
const int COUNT = 10000000;
myClass** objects = new myClass*[COUNT];
(heap because of stackoverflow)
I got 3582 native and 1612 with /clr
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
gajatko wrote: I got 3582 native and 1612 with /clr
Which numbers are you reporting there?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
start = clock();
for (int i = 0; i < COUNT; i++) {
objects[i] = new myClass();
delete objects[i];
}
printf("Native with delete: %f\n", (double)(clock() - start) / CLOCKS_PER_SEC * 1000);
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
Try this (and do NOT run in the debugger!)
class myClass
{
};
int _tmain(int argc, _TCHAR* argv[])
{
const int COUNT = 1000000;
myClass** objects = new myClass*[COUNT];
clock_t start1 = clock();
for (int i = 0; i < COUNT; i++)
{
objects[i] = new myClass();
delete objects[i];
}
clock_t end1 = clock();
clock_t start2 = clock();
for (int i = 0; i < COUNT; i++){
objects[i] = new myClass();
}
clock_t end2 = clock();
clock_t start3 = clock();
for (int i = 0; i < COUNT; i++){
delete objects[i];
}
clock_t end3 = clock();
printf("Loop with new/delete: %d\n\n", end1 - start1);
printf("Loop with new: %d\n", end2 - start2);
printf("Loop with delete: %d\n", end3 - start3);
printf("Total of loop new and loop delete: %d\n", end3 - start2);
printf("\n\nPress enter to end...");
getchar();
delete[] objects;
return 0;
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: Try this (and do NOT run in the debugger!)
Did you look something like this[^] while typing that in?
led mike
|
|
|
|
|
LMAO! You betcha!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Good one! Personally I get used to strange things happening with M$ implementation of Java VM*, so I look like this constantly when programming. Uhm something wrong with logic is here but who cares.
Cheers
* - ok, just kidding.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
gajatko wrote: I get used to strange things happening with M$ implementation of Java VM*
Yeah, cause the Sun VM was perfectly stable.
led mike
|
|
|
|
|
OK so what should I see?
I get results:
For /clr:
Loop with new/delete: 174
Loop with new: 101
Loop with delete: 77
Total of loop new and loop delete: 178
Press enter to end...
for not /clr:
Loop with new/delete: 306
Loop with new: 90
Loop with delete: 64
Total of loop new and loop delete: 154
Press enter to end...
And I neither run from IDE nor in Debug mode.
According to a "you pay as you go" C++ philosophy the result should be the same.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
|
By the way, just curious - what's your test platform (CPU(s)/speed)
and compiler version?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: and compiler version?
Capt. Crunch 3.5
led mike
|
|
|
|
|
Heh[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Vista B. x64 SP 1 Intel Quad 2.4, 2 GB RAM, VS 2008
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|