What is the difference between C language and C
1. C language is process-oriented, while C is object-oriented;
2. The standard function library of C language is very loose, while C is very tightly integrated for most functions;
3. Structures in C language only have member variables, while structures in C , there can be member variables and member functions.
Differences in syntax
struct
In C language, try the defined struct Type variable method: struct [defined variable] [generated variable]; in C language, try the defined struct type variable method: struct [defined variable] [generated variable] or [defined variable] [generated Variables].
In C language, there cannot be functions in variables defined by struct, but in C, there can be functions.
The parameters and return value of the function (take test() as an example)
In C language, it means that the parameters are optional and the return value is int; in C, it means a parameterless function, because No return value results in a syntax error, except when the function without a return value is a constructor.
malloc
The return value of the malloc function is void*. In C language, it can be assigned to any type of pointer. In C, mandatory type conversion must be performed, otherwise an error will be reported.
malloc, free and new, delete
malloc and free can be used in both C and C, but in C, new and delete are more commonly used. malloc and free are functions, while new and delete are operators. The operations of the two sets of heap memory cannot be mixed.
struct and class
class is an extension of struct. The default access permission of struct is public, while the default access permission of class is private.
Recommended tutorial: "C#"
The above is the detailed content of What is the difference between C language and C++. For more information, please follow other related articles on the PHP Chinese website!