Guest User

Untitled

a guest
Jan 18th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. typedef enum VALUE_TYPE {
  2. VT_INTEGER, VT_STRING, VT_BOOL, VT_NULL
  3. } valuetype_t;
  4.  
  5. typedef struct VALUE {
  6. void *iv;
  7. valuetype_t tp;
  8. } value_t;
  9.  
  10. void HacerAlgoQueNoRetorna(void);
  11.  
  12. void MiVariable; /* Imposible! Se desatarán las aguas si esto pasase. */
  13.  
  14. void MiVariable = HacerAlgoQueNoRetorna(); /* ¡RENUNCIO! */
  15.  
  16. void HacerAlgo() {} /* Sí, entre esos paréntesis. */
  17.  
  18. int main(void) {
  19. HacerAlgo(10, 15, 20); /* Es totalmente normal, no pasará nada. */
  20. }
  21.  
  22. void HacerAlgo(void) {} /* Sí, entre esos paréntesis. */
  23.  
  24. int main(void) {
  25. HacerAlgo(10, 15, 20); /* Es totalmente normal, espera... ¡ERROR! */
  26. }
  27.  
  28. (void)fread(mi_contenido, 1, total, mi_archivo);
  29.  
  30. void *malloc(size_t sz);
  31. void *calloc(size_t *sz, size_t nelem);
  32. void *realloc(void *old, size_t new_size);
  33.  
  34. void *mi_memoria = calloc(1, 1000); /* Reservamos 1000 bytes. */
  35.  
  36. #include <stdio.h>
  37. #include <stdlib.h>
  38.  
  39. int main(void) {
  40. void *mi_memoria = calloc(1, 1000);
  41. int *como_int = mi_memoria; /* No hay problema alguno. */
  42. int t = 0;
  43. int sz = (1000 / sizeof(int)) - sizeof(int); /* Sepamos el tamaño. */
  44. while (t <= sz)
  45. como_int[t] = t * 4;
  46. t = 0;
  47. while (t <= sz)
  48. printf("como_int[%d] = %dn", t, como_int[t]);
  49. free(mi_memoria);
  50. return 0;
  51. }
Add Comment
Please, Sign In to add comment