Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Autor : Tiago Portela
- Email : sapitando@gmail.com
- Sobre : Compilado com GCC e LCC.
- Obs : Apenas tentando aprender algoritimos, sozinho, por hobby. */
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdint.h>
- #include <string.h>
- #include <conio.h>
- int main(void){
- void **lpGP = calloc(3,sizeof(void*));
- lpGP[0] = malloc(11 * sizeof(char));
- strcpy(((char**)(lpGP))[0], "ABCDEFGHIJ");
- // strcpy(&((char**)(lpGP))[0][0], "ABCDEFGHIJ");
- // strcpy((char*)(lpGP[0]), "ABCDEFGHIJ");
- // strcpy(&((char*)(lpGP[0]))[0], "ABCDEFGHIJ");
- lpGP[1] = malloc(2 * sizeof(int));
- ((int**)(lpGP))[1][0] = 250;
- // *(*(((int**)(lpGP)) + 1) + 0) = 250;
- // ((int*)(lpGP[1]))[0] = 250;
- // *((int*)(*(lpGP + 1)) + 0) = 250;
- // *(int*)((char*)(*(lpGP + 1)) + (0 * sizeof(int))) = 250;
- ((int**)(lpGP))[1][1] = 500;
- // *(*(((int**)(lpGP)) + 1) + 1) = 500;
- // ((int*)(lpGP[1]))[1] = 500;
- // *((int*)(*(lpGP + 1)) + 1) = 500;
- // *(int*)((char*)(*(lpGP + 1)) + (1 * sizeof(int))) = 500;
- lpGP[2] = malloc(2 * sizeof(float));
- ((float**)(lpGP))[2][0] = 5.25;
- // *(*(((float**)(lpGP)) + 2) + 0) = 5.25;
- // ((float*)(lpGP[2]))[0] = 5.25;
- // *((float*)(*(lpGP + 2)) + 0) = 5.25;
- // *(float*)((char*)(*(lpGP + 2)) + (0 * sizeof(float))) = 5.25;
- ((float**)(lpGP))[2][1] = 10.50;
- // *(*(((float**)(lpGP)) + 2) + 1) = 10.50;
- // ((float*)(lpGP[2]))[1] = 10.50;
- // *((float*)(*(lpGP + 2)) + 1) = 10.50;
- // *(float*)((char*)(*(lpGP + 2)) + (1 * sizeof(float))) = 10.50;
- printf("%p -> %p\n", (void*)(&lpGP), (void*)(lpGP));
- puts("");
- printf("%p -> %p\n", (void*)(&lpGP[0]), lpGP[0]);
- // printf("%p -> %p\n", (void*)(lpGP + 0), *(lpGP + 0));
- printf("%p -> %p\n", (void*)(&lpGP[1]), lpGP[1]);
- // printf("%p -> %p\n", (void*)(lpGP + 1), *(lpGP + 1));
- printf("%p -> %p\n", (void*)(&lpGP[2]), lpGP[2]);
- // printf("%p -> %p\n", (void*)(lpGP + 2), *(lpGP + 2));
- puts("");
- printf("%p = %s\n", (void*)(&((char*)(lpGP[0]))[0]), &((char*)(lpGP[0]))[0]);
- // printf("%p = %s\n", (void*)((char*)(*(lpGP + 0)) + 0), ((char*)(*(lpGP + 0)) + 0));
- puts("");
- printf("%p = %i\n", (void*)(&((int*)(lpGP[1]))[0]), ((int*)(lpGP[1]))[0]);
- // printf("%p = %i\n", (void*)((int*)(*(lpGP + 1)) + 0), *((int*)(*(lpGP + 1)) + 0));
- // printf("%p = %i\n", (void*)((char*)(*(lpGP + 1)) + (0 * sizeof(int))), *(int*)((char*)(*(lpGP + 1)) + (0 * sizeof(int))));
- printf("%p = %i\n", (void*)(&((int*)(lpGP[1]))[1]), ((int*)(lpGP[1]))[1]);
- // printf("%p = %i\n", (void*)((int*)(*(lpGP + 1)) + 1), *((int*)(*(lpGP + 1)) + 1));
- // printf("%p = %i\n", (void*)((char*)(*(lpGP + 1)) + (1 * sizeof(int))), *(int*)((char*)(*(lpGP + 1)) + (1 * sizeof(int))));
- puts("");
- printf("%p = %f\n", (void*)(&((float*)(lpGP[2]))[0]), ((float*)(lpGP[2]))[0]);
- // printf("%p = %f\n", (void*)((float*)(*(lpGP + 2)) + 0), *((float*)(*(lpGP + 2)) + 0));
- // printf("%p = %f\n", (void*)((char*)(*(lpGP + 2)) + (0 * sizeof(float))), *(float*)((char*)(*(lpGP + 2)) + (0 * sizeof(float))));
- printf("%p = %f\n", (void*)(&((float*)(lpGP[2]))[1]), ((float*)(lpGP[2]))[1]);
- // printf("%p = %f\n", (void*)((float*)(*(lpGP + 2)) + 1), *((float*)(*(lpGP + 2)) + 1));
- // printf("%p = %f\n", (void*)((char*)(*(lpGP + 2)) + (1 * sizeof(float))), *(float*)((char*)(*(lpGP + 2)) + (1 * sizeof(float))));
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement