⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ttest.cpp

📁 VC源代码大全(精华版)
💻 CPP
字号:
#include    <stdio.h>
#include    <time.h>

void    TimeTestIndex();
void    TimeTestPointer();

int main()
{
time_t tStart, tEnd;
long y;

    time (&tStart);
    for (y = 0; y < 10000000; ++y)
        TimeTestIndex();
    time (&tEnd);
    printf ("Time elapsed = %ld\n", tEnd - tStart);

    time (&tStart);
    for (y = 0; y < 10000000; ++y)
        TimeTestPointer();
    time (&tEnd);
    printf ("Time elapsed = %ld\n", tEnd - tStart);
    return (0);
}

void TimeTestIndex()
{
char str1[] = "The quick red fox jumps over the "
              "lazy dog's back. RY Testing";
char str2[124];
int    i = 0;
int    j = sizeof (str1);

    do
        {
        str2[i] = str1[i];
        } while (i++ < j);
}

void TimeTestPointer()
{
char str1[] = "The quick red fox jumps over the "
              "lazy dog's back. RY Testing";
char str2[124];
char *pstr1 = str1;
char *pstr2 = str2;

    do
        {
        *pstr2++ = *pstr1++;
        } while (*pstr1);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -