Staredit Network > Forums > Technology & Computers > Topic: C++ GetTickCount()
C++ GetTickCount()
Mar 25 2008, 5:22 pm
By: Test  

Mar 25 2008, 5:22 pm Test Post #1



I can't seem to get the GetTickCount() function to work properly when using C++. I am using Visual C++ 2005 Express Edition. Is there a header I need to include? I can't find it anywhere, all i can find is lots of people asking about this, and getting answers that don't work. I heard that it is only a windows function, and I'm using windows.

I'm using in the srand(GetTickCount) function so it will get random data each time for the rand() function.

The error says:
Quote from Error
1>h:\visual studio 2005\projects\random data\random data\main.cpp(58) : error C3861: 'GetTickCount': identifier not found

Here's my code:
Code
#include <iomanip>
#include <iostream>

using namespace std;

int MostFrequent(int *data) { ... }
int LeastFrequent(int *data) { ... }
int Mean(int *data) { ... }

void main()
{
    int mostFrequent, leastFrequent; // themost and least frequent number
    double mean; // the mean of all of the random numbers
    int randInt[1000]; // array which gets filled up with random integers from 0-1000
    int data[1000] = {0}; // array with 1000 elements of 0
   
//set the random numbers to be random each time
//-- ERROR -->     srand(GetTickCount());

//randomize an int from 0-999 storing it in an array, and adding
//a count to another array to keep track of how many there are.
    for ( int x = 0; x < 1000; x++ )
    {
        randInt[x] = ( ( ( rand() * 1000 ) / RAND_MAX ));
        data[randInt[x]]++;
    }

//call functions and return most and least frequetn integers, and the mean.
    mostFrequent = MostFrequent(data);
    leastFrequent = LeastFrequent(data);
    mean = Mean(randInt);

//display the information to the user
    cout << "Most Frequent:" << setw(6) << mostFrequent << " appeared " << data[mostFrequent] << " times." << endl;
    cout << "Least Frequent: " << setw(4) << leastFrequent << " appeared " << data[leastFrequent] << " times." << endl;
    cout << "The mean is: " << mean << endl << endl;

//allow the user to view the results before quitting
    system("pause");

}//end main

Any help would be nice, unless you know of an alternate way of getting actual random data every time the program is run. If you need any more information please ask.



None.

Mar 25 2008, 7:05 pm ShadowFlare Post #2



#include <windows.h>



None.

Mar 25 2008, 10:25 pm Test Post #3



I remember trying that, and it didn't work... I'll try it again tomorrow when I'm at school. Thanks.



None.

Mar 26 2008, 3:02 am ShadowFlare Post #4



Well, that is certainly the required header file. If it doesn't work, it just means you don't have it installed or one of the files it needs. If that is the case, then maybe try Visual C++ 2008 Express Edition instead, because that will be easier to get the Windows platform SDK stuff set up properly (since it comes with it on that version).



None.

Mar 26 2008, 4:06 pm Test Post #5



Okay, well I'll see if I can get the IT guy to get that installed..



None.

Mar 29 2008, 10:13 am ShadowFlare Post #6



If you want to call functions in Windows then it's either installing that or the Windows Platform SDK and getting that set up for Visual C++ 2005 Express, which is more difficult to get working than just simply installing Visual C++ 2008 Express, which includes that SDK and sets it up in the program for you.

BTW, have you considered using anything else as an alternative to GetTickCount?



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[02:13 pm]
Vrael -- pee poo sibling
[2026-6-28. : 7:00 pm]
Symmetry -- poo poo papa
[2026-6-28. : 2:46 pm]
lil-Inferno -- pee pee child
[2026-6-27. : 6:10 pm]
Ultraviolet -- sweet summer child
[2026-6-26. : 10:31 am]
NudeRaider -- blessed innocent soul knows nothing of the strife we had before EUDs were discovered :teehee:
[2026-6-23. : 3:29 am]
DarkenedFantasies -- Probably just didn't care. For example, at some point before release, they've updated the graphics of some of the Protoss buildings (Forge, CyberCore, Citadel, Observatory, Arbiter Tribunal), but instead of properly re-rendering them with edited 3D models, they did crappy copy-paste jobs on the rendered graphics.
[2026-6-22. : 8:35 pm]
Ultraviolet -- :wob:
[2026-6-21. : 11:38 pm]
Symmetry -- :wob:
[2026-6-21. : 4:56 am]
Ultraviolet -- I suppose we'll likely never know, but my guess would be that they already saw it operating successfully and there was no monetary incentive to finish the original work. And the dev cycle in old school Blizzard was so hectic, it's possible it just got forgotten about after the original game got released. Plus there's an element of existing MPQ files that were packaged with the original discs becoming outdated if they updated it. And it's not like they remade the original MPQs, they just made new ones for BW specifically
[2026-6-21. : 4:26 am]
Oh_Man -- so that makes me think maybe the theory they are unfinished is not true and its a deliberate design decision, coz why not finish them wen ur making brood war?
Please log in to shout.


Members Online: Excalibur, Roy, jy2413804