C language learning + use of Visual Studio 2019

Write C program in Visual Studio 2019

  1. Create a new project
    C language learning + use of Visual Studio 2019
    C language learning + use of Visual Studio 2019
    Click empty project
    C language learning + use of Visual Studio 2019
    configuration New project
    C language learning + use of Visual Studio 2019
    add source file The blue part is the part to be selected
  2. Add the source file test.c and
    C language learning + use of Visual Studio 2019
    change the name to .C form,
  3. Write code
    C language learning + use of Visual Studio 2019
    This is the interface after the project is created.
    Scanf is not supported in Visual Studio 2019,
    so add the following
    #define _CRT_SECURE_NO_WARNINGS 1 to
    prevent errors when compiling the program.
#include<stdio.h>
//包含一个叫stdio.h的文件
//std-标准standard
//i-input
//o-output
//输入输出时的库函数的时候要使用这个头文件
//int整型的意思
//main前面的int表示main函数调用后返回一个整型值
//void main已经过时了
int main() //主函数-程序的入口 main函数有且仅有一个   fn+F10
{
    //这里完成任务
    //在屏幕上输出hello word
    //函数-printf function-printf-打印函数
    //库函数-C语言本身提供给我们使用的函数
    //#include<stdio.h>
    printf("hello word!\n");
    //char - 字符类型
    char ch = 'A';
    int age = 20;
    //short int - 短整型
    //int - 整型
    //long - 长整型
    //%d - 打印整型
    //%c - 打印字符
    //%f - 打印浮点型,打印小数
    //%p - 以地址的形式打印
    long num = 100;
    float f = 5.0;
    double d = 3.14;
    printf("%lf\n", d);//%lf打印双精度小数
    printf("%f\n", f);
    printf("%c\n",ch);//%c打印字符格式的数据
    printf("%d\n",age);//%d打印整型十进制数据
    printf("%d\n",num);
    return 0;
    }

Guess you like

Origin blog.51cto.com/14950896/2539956