QueryPerformanceCounterを使用して、関数にかかる時間をミリ秒単位でカウントしますが、この実行時エラーが発生します。
Run-Time Check Failure #2 - Stack around variable 'time1' is corrupted.
私はすべてを検索して試しましたが、このエラーを理解できません。誰か助けてもらえますか?これが発生するコードです:7
void print()
{
unsigned long int time1 = 0;
unsigned long int time2 = 0;
QueryPerformanceCounter((LARGE_INTEGER*)&time1);
//Loop through the elements in the array.
for(int index = 0; index < num_elements; index++)
{
//Print out the array index and the arrays elements.
cout <<"Index: " << index << "\tElement: " << m_array[index]<<endl;
}
//Prints out the number of elements and the size of the array.
cout<< "\nNumber of elements: " << num_elements;
cout<< "\nSize of the array: " << size << "\n";
QueryPerformanceCounter((LARGE_INTEGER*)&time2);
cout << "\nTime Taken : " << time1 - time2 <<endl;
}