Pointer arithmetic is always in terms of the size of the pointed-to object(s). Incrementing a char*
will advance the address by one, whereas for int*
it would usually be four (bytes). But void
has unknown size, so pointer arithmetic on void*
is not allowed by the standard. Cast to the appropriate type first; if you just want to manipulate the address as if it were a number then cast to char*
or use intptr_t
.
Related Posts:
- waitpid, wnohang, wuntraced. How do I use these
- How to do scanf for single char in C
- Warning: assignment from incompatible pointer type
- Break statement not within loop or switch in C
- How to properly malloc for array of struct in C
- C: error: expected ‘)’ before ‘;’ token
- Where is the C auto keyword used?
- Data argument not used by format strings in C
- execv vs execvp, why just one of them require the exact file’s path?
- difference between
and - Bind failed: Address already in use
- Warning/error “function declaration isn’t a prototype”
- Returning an array using C
- warning: initializer element is not computable at load time
- How to prevent multiple definitions in C?
- How to pass 2D array (matrix) in a function in C?
- How can you print multiple variables inside a string using printf?
- Flushing buffers in C
- What are 0x01 and 0x80 representative of in C bitwise operations?
- How to make parent wait for all child processes to finish?
- Undefined Reference issues using Semaphores
- What is time(NULL) in C?
- Use of cudamalloc(). Why the double pointer?
- C dynamically growing array
- Why should we check WIFEXITED after wait in order to kill child processes in Linux system call?
- Mapping a numeric range onto another
- Why are hexadecimal numbers prefixed with 0x?
- OpenGL — GL_LINE_LOOP —
- How to use EOF to run through a text file in C?
- Valgrind complains with “Invalid write of size 8”
- How to copy a char array in C?
- cast to pointer from integer of different size, pthread code
- Invalid type argument of unary ‘*’ (have ‘int’) Error in C
- Why do I get “cast from pointer to integer of different size” error?
- C subscripted value is neither array nor pointer nor vector when assigning an array element value
- error: too few arguments to function `printDay’ (C language)
- Difference between sizeof(char) and sizeof(char *)
- Where to find the complete definition of off_t type?
- struct has no member named
- printf not printing to screen
- Initializing array of structures
- Still Reachable Leak detected by Valgrind
- How to empty a char array?
- Assembly x86 – “leave” Instruction
- Undefined reference to main – collect2: ld returned 1 exit status
- What is signed integer overflow?
- When to use const char * and when to use const char []
- Is there a way to have printf() properly print out an array (of floats, say)?
- What do numbers using 0x notation mean?
- Can I create an Array of Char pointers in C?
- Does stack grow upward or downward?
- Convert Little Endian to Big Endian
- How do you allow spaces to be entered using scanf?
- Excess elements of scalar initializer for pointer to array of ints
- How does one represent the empty char?
- How to write to a file using open() and printf()?
- Can I define a function inside a C structure?
- Where is the
header file on Linux? Why can’t I find ? - What exactly is meant by “de-referencing a NULL pointer”?
- What is the difference between %g and %f in C?
- Why is the sizeof(int) == sizeof(long)?
- getc() vs fgetc() – What are the major differences?
- Structure padding and packing
- Tokenizing strings in C
- How to allocate array of pointers for strings by malloc in C?
- How to format strings using printf() to get equal length in the output
- “-bash: gcc: command not found” using cygwin when compiling c?
- How to format strings using printf() to get equal length in the output
- In C, what exactly happens when you pass a NULL pointer to strcmp()?
- lseek/write suddenly returns -1 with errno = 9 (Bad file descriptor)
- Should I use printf(“\n”) or putchar(‘\n’) to print a newline in C?
- What do \t and \b do?
- Why and when to use static structures in C programming?
- error: struct has no member named X
- Where does linux store my syslog?
- Example of waitpid() in use?
- Constructor for structs in C
- Can a function return two values?
- C: warning: excess elements in array initializer; near initialization for ‘xxx’ ; expects ‘char *’, but has type ‘int’
- write() to stdout and printf output not interleaved?
- How to know what the ‘errno’ means?
- Split string with multiple delimiters using strtok in C
- Printf was not declared in this scope
- warning: missing terminating ” character [enabled by default]
- How to free memory from char array in C
- Can I get Unix’s pthread.h to compile in Windows?
- Initializing 2D char array in C
- FFT in a single C-file
- Process exited with return value 3221225477
- Implicit function declarations in C
- Convert long long to string in C?
- How do I check if a string contains a certain character?
- Using pointer to char array, values in that array can be accessed?
- How can I create a dynamically sized array of structs?
- malloc(sizeof(int)) vs malloc(sizeof(int *)) vs (int *)malloc(sizeof(int))
- how to stop a loop arduino
- How to normalize a mantissa
- Level vs Edge Trigger Network Event Mechanisms
- How to use shared memory with Linux in C
- When is it ok to use a global variable in C?