Home > Back-end >  C learning path 1 writing format, requirements, understand
C learning path 1 writing format, requirements, understand

Time:09-19

Establish a c + + project: console application project. CPP
C + +, object-oriented programming
The header file: # include , the variable is not in header files, in the namespace
Namespace using namespace STD + (or define your own)
Output: cout & lt; <+ name of the variable input: cin & gt;> + variable name
Line breaks and empty buffer: endl
After the input output: cin> a; Cout: : is the scope operator - & gt; Nothing is in front of the global variable
The same scope can't have two of the same variable, but it is possible to define a namespace, different namespace is the scope of the
Advantages: good for c + + the extensibility and reusability
Method of use: (1) : coutOutside in the open the namespace: using the namespace Bird;
Can also be STD: : coutThe breakpoint must start debugging -- -- -- -- -- & gt; Can you tell where is the collapse - & gt; Manually add pause: system (" pause "); -- -- -- -- -- -- -- -- -- -- & gt; CMD console
Type the command
BOOL header file is # include & lt; Windows. H> BOOL is four bytes, rename, integer BOOL is char renaming, one byte
/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- C -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - */
Define a string: char str1 [10]="abcd";//the stack area
Char * str2=(char *) malloc (10);//a pointer to a character constant area, cannot be modified, can't delete
Str2="asdfgh";
Free (str2);
Str2=0;
Will crash, because both are not allowed to=assignment, may be initialized=
By the copy of the string strcpy_s (target, the target size, source);
/* -- -- -- -- -- -- -- -- c + + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
- # include
#include//note the difference between the header file
Int main ()
{
String STR="aaa";
CoutSTR="asdfgh";//can modify

STR=STR + "ZXCVB";//string splicing
Cout
Cout<(STR=="aaa") & lt;
return 0;
}







Dynamically allocated memory and release
//new an integer
Int * p=new int.
* p=100;
The delete p;
P=0;
//new an integer array
Int * arr=new int [10]. Int * arr=new int (10);
The delete [] arr; This is assigned an integer, with 0 directly initialized this space
Arr=0;
//new an integer pointer
Int * * p2=new int *;
Delete the p2.
The p2=0;
//new an integer pointer array
Int * (* p3)=new int * [3].
The delete p3;
P3=0;
A two-dimensional array//new
Int (* p4) [4]=new int [3] [4].
The delete [] p4.
P4=0;
//new a structure
//the new pointer to an array

Pointer: 1. The memory address (2) indirect operation
Different ways of writing can understand into different meanings
Int * p: define a variable
Int * p: define a pointer to an integer space
Pointer is called * p, * p removed, the remaining space is to operation

CodePudding user response:

No, not the last new

CodePudding user response:

You should be trying to write blog , BBS (to discuss)

CodePudding user response:

refer to the second floor Italink response:
you should be trying to write blog , BBS (to discuss)

How ah, ha ha ha ha, just started playing this not

CodePudding user response:

Much new

CodePudding user response:

Weak weak ask, university computer professional is what language?

CodePudding user response:

I am an inter-bank, but c/c + + computer professional is required

CodePudding user response:

reference rustling, 4/f, shaw, reply:
much new

Ha ha, the whole wrong, didn't know this is a BBS, not a blog