vs2015编写基本C

由于论文需要,要对一些基本的操作进行运行时间的比较,用c语言比较合适,所以一下为用vs2015编写c语言的步骤。
首先,打开vs2015,选择 新建项目
这里写图片描述

然后出现新建项目的界面,选择VC++的编写环境,点击确定。
这里写图片描述

点击下一步
这里写图片描述
选择空项目
这里写图片描述

项目已经建好,右击源文件添加新建项。
并且命名为.c后缀
编好之后,注意按ctrl+F5,否则会出现程序框“一闪而过”的情形。

如果要计算程序运行时间,

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main()
{
    clock_t begin, end;
    double cost;
    //开始记录
    begin = clock();
    /*待测试程序段*/
    printf("hello world!\n");
    //结束记录
    end = clock();
    cost = (double)(end - begin)/CLOCKS_PER_SEC;
    printf("constant CLOCKS_PER_SEC is: %ld, time cost is: %lf secs", CLOCKS_PER_SEC, cost);
}

猜你喜欢

转载自blog.csdn.net/shirleycyy/article/details/79977427
今日推荐