A way of communication between humans and computers.
C language is suitable for Linux embedded. Gadgets.
The Mac computer is the UNIX kernel.
Second, the basic operation of Linux
#vi A.C New File
#rm A.C Delete Files
I current cursor before insertion
A is inserted after the current cursor
Shift+a Line End Insertion
Shift+i Line Header Insertion
o Insert Next line
Shift+o the previous line inserts
DD deletes the cursor in the row
Three Linux under the first C program
Vim A.C
#include <stdio.h>int main () { printf ("Hello word!\n"); return0;}
GCC A.C compiled to get a.out
./a.out Run Program output results
Chapter Fourth multi-file operations
Multi-file divide and conquer
Vim can open another file at the same time when opening a file. Enter in the command state: SP MAX.C is a new max.c file and opens at the same time.
The ctrl+w can be toggled between files.
: Set Nu Open line number
Enter the line number by DD to cut the cursor to the part of the line number to the Clipboard. P Paste
GCC hello.c max.c-o hello.out compiles hell.c and max.c to Hello.out
header file separated from function definition
Gcc-c max.c-o MAX.O First compile max.c
GCC MAX.O hello.c compiles the compiled MAX.O and hello.c together.
The header file is only declared on the line. and do not compile. Retained directly in the software system.
The fifth chapter MakeFile's writing and using
The Make tool divides large development projects into several modules. Using the Make tool, it is clear and quick to organize your source files.
First check to see if the Make tool is installed.
VI MakeFile//It all seems to be the name
# This is a make file which is a comment. GCC Front is a tab.
This is Make Filehello. out : MAX.O min.o hello.c -o hello.omax.o:max.c -c max.cmin.o:min.c c min.c
Make executes the makefile directly to compile the program. When re-executing, compile files that have never been compiled directly.
Sixth Chapter main function detailed
Return in the main function
The full version of the main function.
# include <stdio.h>intint argv,Char* argc[]) { printf (" Hello word"); return 0 ;}
GCC main.c-o main.out &&./main.out here && indicates that the previous execution succeeds after the execution of the following. How do I tell if the first sentence is successful?
echo $? The output execution succeeded (returning 0 indicates that it was executed correctly, otherwise it failed.) )
Here the echo output of 0 is above the return0;
After modification:
# include <stdio.h>intint argv,Char* argc[]) { printf (" Hello word"); return 101 ;}
GCC main.c-o main2.out &&./main2.out to output normally
echo $? The output is 101.
./main2.out && ls Here you can only output the operating results normally. The LS command is not executed after &&.
So return 0; don't write casually.
Parameters in the main function
ARGV is the number of arguments. Argc[] Stores the contents of the parameter.
# include <stdio.h>intint argv,Char* argc[]) { printf (" ARGV is%d\n", argv); int i; for (i=0; i<argv; i++) { printf ("argc[%d] is%s!\n" , I,argc[i]); } return 0 ;}
GCC main2.c-o m4.out Compilation
EG1:./m4.out execution
Execution results
ARGV is 1
Argc[0] is./m4.out!
Eg 2:./m4.out QW werer DS executes and gives multiple parameters
Execution results
ARGV is 4
Argc[0] is./m4.out!
ARGC[1] is qw!
ARGC[2] is werer!
ARGC[3] is ds!
Seventh chapter input output stream and error stream
Standard input stream output stream and error flow
redirect
Eighth chapter Piping Principle and application
The Nineth chapter builds the practical C language Small program
Linux C Programming Fundamentals and Practice notes GCC MAX.O hello.c