TechGlider
09-03-2009, 07:16 PM
I am trying to figure out why my value isn't being passed to my main function.
void passValue(int a[], int n, int executionCount)
{
for(int i = 1; i < n; i++)
{
while(i < n; i++)
{
executionCount++;
}
}
}
int main()
{
int n = 20;
int *a = (int*) calloc(n, sizeof(int));
int executionCount = 0;
srand(time(NULL));
passValue(a, n, executionCount);
for(int i = 0; i < n; i++)
{
txtFile << a[i] << " ";
}
txtFile << "\n" << "Executions: " << executionCount;
I removed most of the non-trivial code.
when printing, executionCount = 0 while in the passValue() function, it registers a different value, the one that should be printed.. also how can i calculate the time it takes for the passValue function to execute?
void passValue(int a[], int n, int executionCount)
{
for(int i = 1; i < n; i++)
{
while(i < n; i++)
{
executionCount++;
}
}
}
int main()
{
int n = 20;
int *a = (int*) calloc(n, sizeof(int));
int executionCount = 0;
srand(time(NULL));
passValue(a, n, executionCount);
for(int i = 0; i < n; i++)
{
txtFile << a[i] << " ";
}
txtFile << "\n" << "Executions: " << executionCount;
I removed most of the non-trivial code.
when printing, executionCount = 0 while in the passValue() function, it registers a different value, the one that should be printed.. also how can i calculate the time it takes for the passValue function to execute?