Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define ARRAY_SIZE (5)
- int main(void) {
- int i;
- char array_char[ARRAY_SIZE] = {'a', 'b', 'c', 'd', 'e'};
- int array_int[ARRAY_SIZE] = {1, 2, 3, 4, 5};
- void *pointer_void;
- pointer_void = (void *)array_int;
- for (i = 0; i < ARRAY_SIZE; i++) {
- printf("pointer_void は %p を指しており,値は '%d' です.\n", pointer_void,
- *(int *)pointer_void);
- pointer_void = (int *)pointer_void + 1;
- }
- pointer_void = (void *)array_char;
- for (i = 0; i < ARRAY_SIZE; i++) {
- printf("pointer_void は %p を指しており,値は '%c' です.\n", pointer_void,
- *(char *)pointer_void);
- pointer_void = (char *)pointer_void + 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement