vs2015 writing basic C

Due to the needs of the paper, it is more appropriate to use the C language to compare the running time of some basic operations, so the following are the steps to write the C language in vs2015.
First, open vs2015 and select New Project
write picture description here

Then the interface for creating a new project appears, select the VC++ writing environment, and click OK.
write picture description here

Click Next
write picture description here
Select Empty Project
write picture description here

The project has been built, right-click the source file to add a new item.
And the name is .c suffix After
editing , pay attention to press ctrl+F5, otherwise the program box "flashes" will appear.

If you want to calculate the program running time,

#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);
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324527865&siteId=291194637