+ 1

How a pointer of data type char having 1byte size stores the address of more size?

https://code.sololearn.com/cLSy0IdqBDBG/?ref=app

21st Apr 2019, 5:43 AM
Suraj Dhenge
Suraj Dhenge - avatar
3 ответов
+ 3
Suraj Dhenge Wikipedia will explain this better than me https://en.wikipedia.org/wiki/Word_(computer_architecture)
21st Apr 2019, 6:02 AM
KrOW
KrOW - avatar
+ 2
Any pointers type (int*, char*, void* etc) have same machine word size (usually 4/8 bytes) and it store only the ADRESS OF FIRST BYTE OF DATA in memory. In your case, the code allocate an array of char containing the chars "String" then assign to p the adress of first "data" to it (the adress of 'S' char in memory)
21st Apr 2019, 5:56 AM
KrOW
KrOW - avatar
+ 1
KrOW what is the size of pointer type in 64-bit machine? 4/8byte?
21st Apr 2019, 5:58 AM
Suraj Dhenge
Suraj Dhenge - avatar