Home > Back-end >  C language array length
C language array length

Time:10-01

could you tell me how to get like this is what happens to the length of the array of 8

CodePudding user response:

No way, only oneself control
Such as array initialization of each element is 0, then cyclic statistics there are a number of non-zero elements

CodePudding user response:

reference 1st floor qybao response:
can't, can oneself control
Such as array to initialize each element is zero, then the circulation statistics there are a number of non-zero elements
like sizeof (s)/sizeof (s [0]) like this don't do that if the user enters a dozen number how do I know this length

CodePudding user response:

The variable usually includes function arguments and function in the stack declared temporary variables,
The basic variables of the stack exit its scope, who did not perform a piece of code to release/destroy/destructor of memory, it occupies only is no one to stay at the top of the current stack of several legacy can be covered by subsequent pressure stack, useless data,
And the class variables in the stack exit its scope, will automatically perform its destructor,...

Actually computer after each byte of physical memory has values and is read/write, never because of the so-called new, delete or malloc, free and is created and destroyed, the difference only lies in the operating system memory management module can find when you read and write and whether to take appropriate action, and the granularity of the operating system manages memory rather than bytes page, a page is usually 4 KB,

Why do you want to have a data structure, the east east?
Because in the real world or abstract theory to a variety of data stored in the computer peripheral storage (CD, hard disk, U disk... ) or (ROM, RAM, SRAM memory... Binary byte array),
Then let the CPU will only perform shift preserved good addition, subtraction, multiplication, and division conditional transfer... Machine instructions, such as the guy in accordance with the will of people to deal with these data, as for the specific how to deal with the so-called algorithm,

Recommended WinHex software to check the hard disk or file or original bytes of memory content,

CodePudding user response:

Computer memory or file content or transport it is just a one-dimensional binary byte array and its corresponding binary address;
The human brain to a computer memory or file contents or transfer the content of the one-dimensional binary byte array and its corresponding binary address some parts as an integer, number of signed/unsigned number, floating point Numbers, complex Numbers, letters, digits, Chinese/Korean/French... Character/string, assembly instructions, functions, function parameters, heap, stack, arrays, Pointers, array pointer and pointer array, the array of arrays, pointer to pointer, two-dimensional arrays, character lattice, the coordinates of character strokes, black and white binary images and grayscale images, color images, audio, video, fingerprint information, id information...

CodePudding user response:

refer to the second floor m0_46244162 response:
Quote: refer to 1st floor qybao response:
can't, can oneself control
Such as array to initialize each element is zero, then the circulation statistics there are a number of non-zero elements
like sizeof (s)/sizeof (s [0]) like this don't do that if the user enters a dozen number how do I know this length
can't, you can only record the length of the
Many data structure with a length variable to your statistics, add elements length++, length - remove elements
  • Related