
for you rambowians
By: a guest on
Sep 27th, 2012 | syntax:
C | size: 0.72 KB | hits: 36 | expires: Never
#include <stdlib.h>
#include <stdio.h>
/*
change this to whatever amount
of iterations you want.
*/
#define COUNT 2000000000
int main(int argc, char* argv[])
{
int type, i;
printf("Args: %d\n", argc);
if (argc < 2)
{
printf("Usage: <program name> <type>\n");
printf("where <type> is either 0 (for) or 1 (while).\n");
return EXIT_FAILURE;
}
type = atoi(argv[1]);
if (type == 0)
{
printf("Testing for loop...\n");
for (i = 0; i <= COUNT; i++)
{
// pass
}
}
else if (type == 1)
{
printf("Testing while loop...\n");
i = 0;
while (i <= COUNT)
{
i++;
}
}
else
{
printf("Invalid arguments...\n");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}