How many bits are needed

I’ve stumbled across a problem: How many bits are needed to address a 10kB data memory if one cell is 1 byte in size? so when I try to solve this question the only thing I can solve is what’s the amount of cells but not how many bits are needed to address a 10kB… Read More How many bits are needed

Why is my interface containing a pointer not updating after the pointer is updated?

I have a lot of constraints in the issue I am encountering, so I have greatly simplified it to this unnatural code containing the following stuff: A struct named Rect rA and rB both of which point to a new Rect object r1 and r2, which are interfaces containing rA and rB r1Adr and r2Adr,… Read More Why is my interface containing a pointer not updating after the pointer is updated?

Why is my interface containing a pointer not updating after the pointer is updated?

I have a lot of constraints in the issue I am encountering, so I have greatly simplified it to this unnatural code containing the following stuff: A struct named Rect rA and rB both of which point to a new Rect object r1 and r2, which are interfaces containing rA and rB r1Adr and r2Adr,… Read More Why is my interface containing a pointer not updating after the pointer is updated?

Why the datatype of the pointer should be same as the datatype of the variable to which it is addressing?

Code snippet 1: int main(){ float fl; int *i=&fl; } The error was: error: cannot convert ‘float*’ to ‘int*’ in initialization int *i=&fl; Code snippet 2: int main(){ int i; float *fl=&i; } The error was: error: cannot convert ‘int*’ to ‘float*’ in initialization float *fl=&i; Question The datatype only helps in allocating the required… Read More Why the datatype of the pointer should be same as the datatype of the variable to which it is addressing?

Child processes are sharing the same variable in memory which is created after fork() is called (C)

I am working on a script where fork() is called in a for loop to create many children, these children do a random number of loops and then print the name of the child I’m having some odd behavior where the memory address that i is at is shared for all of the child processes… Read More Child processes are sharing the same variable in memory which is created after fork() is called (C)

Why do i get 2 different output from when printing out the sizeof() pointer vs variable

Why do i get 2 different output from when printing out the value in the same address? the pointer ptr is pointing at the index 0 of the accessed Element (bar). yet is showing me different results? unsigned int bar[5]; int main(){ unsigned int * ptr = &bar[0]; printf("%lu\n",sizeof(ptr)); // Console output : 8 (bytes)… Read More Why do i get 2 different output from when printing out the sizeof() pointer vs variable

What is the difference between the address value from instance and the address value from id(instance) in python?

class T: pass t = T() print(t) # <__main__.T object at 0x100651460> print(id(t)) # 4301591648 What is the difference between 0x100651460 and 4301591648 in the code above? id(t) is to print the address value of the object as everyone knows. However, <main.T object at 0x100651460> also implies that 0x100651460 is the address value of the… Read More What is the difference between the address value from instance and the address value from id(instance) in python?