You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

33 lines
651 B

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. int foo(int age) {
  5. int result;
  6. time_t t = time(NULL);
  7. result = localtime(&t)->tm_year + 1900 - age;
  8. return result;
  9. }
  10. int main() {
  11. const int x = 10;
  12. const int *q = &x;
  13. const int *const p = malloc(sizeof(int) * 5);
  14. for (int *i = (int *)p; i < p + 5; ++i) {
  15. *i = x;
  16. printf("%p%c", i, (i < p + 4 ? ' ' : '\n'));
  17. }
  18. for (int *i = (int *)p; i < p + 5; ++i) {
  19. scanf("%d", i);
  20. }
  21. for (int *i = (int *)p; i < p + 5; ++i) {
  22. *i = foo(*i);
  23. printf("%d%c", *i, (i < p + 4 ? ' ' : '\n'));
  24. }
  25. free((int *)p);
  26. }