Home > Back-end > Novice asked a question, a return value of c in the new void * pointer is why
Novice asked a question, a return value of c in the new void * pointer is why
Time:09-16
Run on vs, show is the return value of a new type void *, shouldn't be int * type?
CodePudding user response:
If as you say he is the return value of the int *? Then double * pd=new double [5]; He should be a return to a double * cough up? Why return void *? Because the pointer footprint size are the same, void *, int *, double * is four bytes in a 32-bit system, inside with directed address, just depends on what type of you use pointer to save this address
CodePudding user response:
Allocate a block of memory from the heap, the memory and not sure what type!
CodePudding user response:
Void * is common to other type also more convenient it is ok to just write a return void * Otherwise int return int double return double... And so on a lot of trouble
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...
http://edu.csdn.net/course/detail/2344 C language pointer and assembly - a memory address. The code element
CodePudding user response:
New int [...]. This expression is called operator new [] (... ) to allocate memory, the latter return void *, but in the end, the results are int *, note that the operator new [] (... ) returns the address of the allocated memory block, the new int [...]. Return to create the address of the first array element, the two may not equal in value,