Don't like ads? PRO users don't see any ads ;-)
Guest

for you rambowians

By: a guest on Sep 27th, 2012  |  syntax: C  |  size: 0.72 KB  |  hits: 36  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. /*
  5.  change this to whatever amount
  6.  of iterations you want.
  7.  */
  8. #define COUNT 2000000000
  9.  
  10. int main(int argc, char* argv[])
  11. {
  12.         int type, i;
  13.         printf("Args: %d\n", argc);
  14.         if (argc < 2)
  15.         {
  16.                 printf("Usage: <program name> <type>\n");
  17.                 printf("where <type> is either 0 (for) or 1 (while).\n");
  18.                 return EXIT_FAILURE;
  19.         }
  20.         type = atoi(argv[1]);
  21.         if (type == 0)
  22.         {
  23.                 printf("Testing for loop...\n");
  24.                 for (i = 0; i <= COUNT; i++)
  25.                 {
  26.                         // pass
  27.                 }
  28.         }
  29.         else if (type == 1)
  30.         {
  31.                 printf("Testing while loop...\n");
  32.                 i = 0;
  33.                 while (i <= COUNT)
  34.                 {
  35.                         i++;
  36.                 }
  37.         }
  38.         else
  39.         {
  40.                 printf("Invalid arguments...\n");
  41.                 return EXIT_FAILURE;
  42.         }
  43.         return EXIT_SUCCESS;
  44. }