One way to learn a new programming language is to write programs in it.

1 Dev-C++

First we need a C IDE, and dev-C ++ is recommended. Dev-c ++ is a lightweight C/C++ integrated development environment (IDE) for beginners on Windows. It is free software and distributes source code under the GPL license. It is a collection of MinGW GCC compiler, GDB debugger, AStyle format collator and many other free software.

After installation, open file → New → Project in the top toolbar:

Once you’re done, specify the path to the file that will be stored in the project.

Next, to customize the editor style, we can open the Tools → Editor option in the top toolbar.

[1] Customize font and size (display TAB)

[2] Custom themes (default in grammar TAB)

Write the first C language program

Let C print out the greetings

#include <stdio.h>
main() {printf("Hello, this is C language \n");
}
Copy the code

Click the shortcut key F11 to compile and run the program and output the following results:

  • #include <stdio.h>Indicates the import of standard input and output library information.
  • \nRepresents a newline character. If you wrap a line, you will get a compilation error:

Call printf() multiple times, and the output lines are concatenated:

#include <stdio.h> 
main() {printf("Hello, THIS is C language. \n");
	printf("Please advise,");
	printf("I hope you are happy every day.");
}
Copy the code

Output result:

Note 3 points

3.1 Must have a semicolon

If you omit the semicolon after printf, you get a compilation error:

3.2 Double Quotation marks on Strings

Strings in the printf() method must be enclosed in double quotes.

If single quotes are used, a compilation error occurs:

3.3 the prefix for\The character of

#include <stdio.h> 
main() {printf("Hello, THIS is C language. \y");
	printf("Please advise,");
	printf("I hope you are happy every day. 7 \ \ 7, 7, 7, 7, 7, 7, 7");
}
Copy the code
  • if\If the following character is undefined, a compile warning will be prompted, as in this case\y:[Warning] unknown escape sequence: '\y'.
  • 7 \Short buzzer, so run this program and you will hear a series of short buzzers