table of Contents
- 1.1 What is the program
- 1.2, why is c language
- 2.3, C language of the birth story
- 2.4, C language development
- Features 2.5, C language
- 2.6, C program development tools
- 2.7, install VC ++ 2010Express
- 2.8, install VC6.0 Chinese version download (support XP, Win7, Win8, Win10)
- 2.9, C developers Getting Started
- 2.10, C program operating mechanism
- 2.11, little exercise
- 2.12, compile, link and run Detailed
- 2.12.1 What is compiled
- 2.12.2 What is the link
- 2.12.3 What is the run
- 2.12.4, C program development Notes
- 2.13, C program development Notes
- 2.14, C escape characters
- 2.15 common problems and solutions
- 2.16 Note (Comment)
- 2.17, standard coding style
- 2.18, little exercise
1.1 What is the program
Program: a collection of ordered instructions for your computer to perform certain actions or to solve a problem and write
For example:
#include <stdio.h>
void main(){
printf("hello,world!");
}
1.2, why is c language
2.3, C language of the birth story
1. Why invention C language: the birth and development of the C language is inseparable from UNIX operating system, the original UNIX operating systems are written in assembly language, in 1973 the core UNIX operating system using C language rewritten, since then, C language as the main language of the operating system
2, affect the C language on other languages: Many programming languages are deeply influenced by the C language, such as C ++ (originally an extension of the C language), C #, Java, PHP, Javascript, Perl, LPC and UNIX CShell and so on.
3, master the C language of people, to learn other programming languages, most of them can get started quickly, by analogy, many universities as the C language teaching introductory computer language
4, inventor: Unix father of Dennis Ritchie C language parent
2.4, C language development
Note: you need to know two important versions 1.ANSIC (Standard C) C language, C892.C99
Features 2.5, C language
1, cross-platform code level : Since the standard of existence, makes it almost the same C code that can be used for a variety of operating systems such as Windows, DOS, UNIX, and so on; also applies to a variety of models.
2, so that allows direct access to the physical address, the hardware to operate : As the C language allows direct access to physical addresses, can operate directly on the hardware, so neither has the function of high-level language, but also has many of the features low-level language, C language available to write system software (such as operating systems, databases, anti-virus software, firewalls, driver, server program).
3, C language is a structured programming , having a variable scope (variablescope) and recurse function of procedural languages
4, C language transmission parameters can be passed by value (passbyvalue, value), may be passed a pointer (apointerpassedbyvalue, address)
5, C language, no object , different types of variables may be combined with the structure (struct) together
6, the pre-compile processing (Preprocessor), generating a target high code quality , program implementation of high efficiency
2.6, C program development tools
2.7, install VC ++ 2010Express
2.7.1, VC ++ 2010Express basic introduction
1, vc2010 place called the microsoftvisualc ++ 2010Express is a product of Microsoft
2, vc2010 is an IDE (Integrated Development Environment), for developing c or c ++ application
3, vc2010 installation, installs runtime components VisualC ++ library that allows users to run applications developed VisualC ++ on a computer
2.7.2, VC ++ 2010Express installation process
1, download and install software
https://download.csdn.net/download/weixin_43089084/10795086
2, need to install networking, and then directly to the next step.
2.8, install VC6.0 Chinese version download (support XP, Win7, Win8, Win10)
2.8.1 Description
1, if you are accustomed to using VC6.0, here we explain how to install and use
2, VC6.0 original Microsoft no longer easy to find, are available online through a third party modified version deleted some use less than the functionality, enhanced compatibility. Here we use VC6.0 full green version
3. After installation, you need win7, win8, win10, do a set of compatibility, click vc6.0 picture, select Properties, as follows
2.9, C developers Getting Started
2.9.1, requirement specification
Hello.c sought to develop a program that can output "hello, world!"
2.9.2, development steps
1. Create an empty project (vc2010 is the project management of the source code), project storage path:
c: \ the Users \ Administrator \ Documents \ VisualStudio2010 \ the Projects
2, the write C code into a file named hello.c file. [Code]
3. Click the implementation (not debug) button to run the program (this button needs to be configured)
4, code demonstrates
//开发项目~~~
//1.引入头文件,后面还会详细介绍
#include<stdio.h>
//说明
//1.这是一个main函数,是程序的执行入口,即程序是从main函数开始执行
//2.void表示main函数没有返回值
//3.main(){//函数体,即一条条语句//}
void main(){
int a=10;
int A=10;
//说明
//1.printf是一个函数,需要是一个头文件才能使用
//2.printf是在<stdio.h>,需要引入该头文件
printf("hello,world你好~!");
getchar();//让窗口停留
}
2.10, C program operating mechanism
2.10.1C running mechanisms (processes) Description
1, edit : for example, the preparation of our hello.c file is the source code.
2. Compile : hello.c program will be translated into object files (hello.obj) // execute the underlying computer
3, the link : the target file hello.obj + library file to generate an executable file (MyProject01.exe) // execute the underlying computer
4. Run : execute .exe file, to get operating results
2.10.2, C illustrate execution flow analysis
2.11, little exercise
1, first create an empty project using vc2010
2, requires the development of a hello2.c program, you can output "so isstudyingc!"
# include <stdio.h>
void main(){
printf("me is studying c !")
getchar();
}
2.12, compile, link and run Detailed
2.12.1 What is compiled
1, with the C source file , which is compiled by a compiler into the obj file (the object file).
2. If the program does wrong, without any prompting, but in the Debug will be a directory Hello.obj file, which is called the target file.
2.12.2 What is the link
1, with the object file (.obj files) , by linking the program to run and needs of c libraries linked into exe file (executable file).
2. If the program does wrong, without any prompting, but there will be a project .exe file name in the Debug directory, the file is called an executable file.
3. Why link library files? Because our C program uses the C library of content, such as functions printf <stdio.h> <stdlib.h> in () system (), etc., these functions are not programs members write their own, but the C library provided, thus requiring link
4, you will find the link, generated exe files , than large obj files a lot.
2.12.3 What is the run
1, with exe executable file, also known as executable (binary)
2, the console can run the exe file directly
2.12.4, C program development Notes
To hello.c source modified files need to be recompiled to link , to generate a new exe file , and then execute, to take effect.
2.13, C program development Notes
1, the main structure of C programs Description
# include ...
void main () {// {} including content, referred to the function body
Statement 1;
sentence 2;
}
2, C source files with "c" extension.
3, the C program execution entry is main () function.
4, C language strictly case-sensitive.
5, C is constituted by a section of the program statements, each of the ";" End
6, the braces are paired, are indispensable
2.14, C escape characters
2.14.1, C common escape characters
1, \ t: a tab stop, to achieve alignment features
2, \ n: line breaks
3, \: a \
4 ": a"
5 ': a'
6, \ r: a carriage return
2.14.2, application examples
void main(){
//演示一下常用转义字符使用
//说明
//1.\t是表示一个制表位
//2.\n表示换行输出
//3.\\第一个\是转义,第二个\表示输出内容
//4.\"第一个\是转义,第二个"表示输出内容
printf("北京\t上海\t天津\n");
printf("张三说你好!\n");
printf("hello,\\world\n");
printf("hello,\"world\n");
printf("hello,\"world\n");
//分析 \r表示回车,不是换行
//1.先输出:张无忌赵敏周
//2.输出芷若小昭敏周
//最后输出结果就是芷若小昭敏周
printf("张无忌赵敏周\r芷若小昭");
2.15 common problems and solutions
3, the error summary
learn programming error is most likely to commit grammatical errors. C language to write code requirements must be in accordance with the rules of grammar. If your program violates the rules of grammar, such as: forget the semicolon, brackets, quotation marks, or a misspelled word, Chinese; and English; C compiler will report a syntax error. Try to understand the error message compiler will report.
2.16 Note (Comment)
2.16.1 introduces:
1, for the annotation caption interpreter is comments, which improves code readability;
2, the comment is a programmer must have good programming practice. Their thoughts by commenting sorted out first, then the code to reflect.
Annotation type 2.16.2, C in
1, single-line comments
2, multi-line comments
2.16.3, single-line comments:
2.16.4, Details
1, for single line and block comments, annotated text will not be executed.
2, block comment does not allow nested block comments
3, shortcuts can be configured to your own habits. (Configure their own after-school look)
4, illustrating the configuration shortcuts
2.17, standard coding style
2.18, little exercise
1, independent program written Helloworld
2, the basic personal information (name, gender, place of birth, address) to print the output on the console. Various pieces of information which accounted for one line (using the escape character, get in a printf statement).
3, programming, with char type, were preserved \ n \ t \ r \ 123 characters, etc., and prints {char behind after completion of the study]
4, C procedures outlined operational mechanism, explained several of his process, and interpret.