I define a struct type as follows: where I have a pointer named obs_data: then I want to assign each object of the obs_data as follows: in the above, event is a struct from the inotify that captures the events associated with changes to a file or directory in Linux. when I run the above chunk of code in my
Tag: pointers
Read number from stdin and save as integer directly, using read() function
when I execute this code, it returns just random integer like 724109877 Why this happend? also glad to hear if someone tells me right way to read number from stdin and save as integer Answer You can do that by reading a line and convert it to a number later: Note that nb_bytes will include the newline character, you can
BUG: unable to handle kernel paging request when accessing a custom struct in syscall
Using linux with kernel 4.4.21, I was required to implement a system call which has a custom struct’s pointer among its parameters. These are the files to to edit: I put sys_procmem.c (implementation) in linux-4.4.21/kernel/sys_procmem.c (sys_procmem.o added in that dir’s Makefile): Test: Both were killed miserably. dmesg: This was done inside a 64-bit Ubuntu 14.04 virtual machine. My friends had
Unsigned long into char array
Here is an example of my code : My question is, why does this last memcpy works ? i would expect to put CRYPTO and not &CRYPTO in arguments… For me, CRYPTO is the value i want so 0xe8ba8fa3 and &CRYPTO the address. And for me, CRYPTO is not a pointer, so why i need to use memcpy with &CRYPTO
C code about pointers
I’ve got this simple code that plays with pointers taken from Jon Eriksen’s book that I’m trying to compile but gcc gives me warnings in compilation and segmentation fault (core dumped) when I run it. Output: Answer This program is wrong, and the advice given in the book is obviously wrong, too. A pointer can be converted to an integer
Segmentation fault while trying to return a pointer to object from a method
g++ throw me ‘segmentation fault’ while I’m trying to return an object of a classB from a method of a classA. I don’t know how to fix this error, if anybody can tell me why this error happens, I would be grateful. So… here is the code: classA.h classA.cpp classB.h classB.cpp main.cpp Makefile SRC = src INC = include OBJ
Pointers and virtual memory [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 years ago. Improve this question According to my system’s cpuinfo file, each processor in my system has a 39 bit physical address size and a 48 bit virtual address size.
How to print the void * in a function and how to access the void * variable in a function?
I’m trying to pass a function as argument to another function with void pointer and it doesn’t work I Am getting errors like this: How do I fix the problem? Answer To print a pointer you need the “%p” printf format. But it seems that you don’t actually want to print the actual pointer but what it points to, and