Use of 1.sizeof: The sizeof operator gives the storage size of its operands in bytes.The sizeof operator cannot be used for a function type, an incomplete type, or a bit field. An incomplete type is a data type with an unknown storage size, such as
The following is a detailed analysis of the details of sizeof in C language, the need for friends can refer to the next
1.sizeof is the operator, which is essentially the same as the nature of the subtraction, executed at compile time, not at
I. macro definition: Mainly some Syntax problems and skills
For example:
# Define find (S, e) (size_t) & (struct s *) (0)-> E) // calculates the offset of the variable in the structure to the struct.
# Define seconds_per_year (360*24*60*60) UL //
Memset has many usage network resources. The following is my personal experience. ========================================================== ======================================
Memset usage(The third parameter is the number of bytes) 1. For the
The result of the sizeof function:
Variable: The number of bytes that the variable occupies.int 0 ;p rintf ("%d\n"sizeof(i)); // 4
Array: The number of bytes that the array occupies.intArr_int1[] = {1,2,3,4,5};intarr_int2[Ten] = {1,2,3,4,5};
1, compile-time calculation operator sizeof, available types or variables to do parameters, calculate the size of memory consumption. If the type must be bracketed after sizeof, the variable name may not be bracketed. sizeof (x) can be used to
Array parameter sizeof, array parameter sizeof
In the following code, when an array is used as a function parameter, the array size needs to be calculated in the function:
Void copy (int a [], int B []) {memcpy (B, a, sizeof ());}
This Code is
Copy Code code as follows:
#include
int main ()
{
int i;
i = 10;
printf ("%d\n", I);
printf ("%d\n", sizeof (i++));
printf ("%d\n", I);
return 0;
}
What should these three lines of output be?
The answer is:10
4
10
The third
first, sizeof gets the number of bytes of an object or type
1. General type
char, int, long, double, etc.
Number of bytes returned and system-related
2. Pointer type
The pointer type is actually the address, 32 is the number of bytes in the system
The sizeof of the C-language plane question
The sizeoftable of the question of C language face Contents
1. sizeof
1sizeofsizeof is the length character of the data type or expression in C, it is not
I. Introduction in the previous article, we created a window from scratch. One important step is to register the window class, such as the following code://Register window class bool Register (LPSTR lpclassname, WNDPROC WNDPROC) {wndclassex WCE = {0}
Met during the interview. The other is how to prevent repeated definitions in header files.
# Ifndef
# Def
# Enddef
Wild pointer, free and then null.
Sizeof (enum_type) C ++ standard p692:
In C ++, the type of an enumerator is its
In VC, sizeof has many usage and may cause some errors. Next, we will summarize the usage of sizeof based on the parameters following sizeof.
A. the parameter is of the data type or is A common variable:
For example, sizeof (int) and sizeof
The following 5 columns are for C + + and do not involve sizeof byte alignment and basic data types that are specific to C + + and are targeted at 32-bit machines
Using sizeof in C + + is much more complicated than C, because there are static
One, C # sizeof operatorThe sizeof operator is used to get the number of bytes of a value type.Ii. examplesUsing System;Using System.Collections.Generic;Using System.Linq;Using System.Text;Namespace Test{Class Program{static void Main (string[] args)
Or in the university era of contact with the C language, when learning arrays, pointers and other concepts, how a "halo" word. Recently in the study, crazy to fill the relevant knowledge, so summed up, if there are errors, please give us a lot of
A summary of the problem of the class-seeking sizeofFirst look at the following code:1 classA2 {3 Public:4 A () {};5~A () {};6 Private:7 intA;8 Doubleb;9 };Ten One classB: PublicA A { - Public: - B () {}; the~B () {}; - Private: -
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.