Лекция 13 - Памет

Линк към презентацията

Б клас

#include <stdio.h>
#include <unistd.h>

int main() {
  int arr[2];

  arr[0] = 3;
  arr[3] = 3;
  arr[10] = 3;
  arr[100] = 3;
  arr[1000] = 3;
  //arr[100000] = 3;

  sleep(100);
  return 0;
}
#include <stdio.h>
#include <stdlib.h>

int main() {
  /*long long int variable = 50;
  long long int *pointer;
  //int* pointer, variable2;
  //int *pointer2, variable3;

  pointer = &variable;
  printf("%p - %d\n", &variable, variable);
  printf("%p - %p - %d\n", &pointer, pointer, *pointer);
  printf("%p - %p - %d\n", pointer+1, (pointer+1), *(pointer+1));*/
  while(1) {
    int *a = (int*)malloc(sizeof(int)*1000);
    int *b = (int*)malloc(sizeof(int)*1000);
  }
  return 0;
}
#include <stdio.h>

int main() {
  int arr[10];
  for(int i=0;i<10;i++) {
    arr[i] = i*13;
  }

  for(int i=0;i<10;i++) {
    printf("[%d] = %d - %p\n", i, *(arr + i), &arr[i]);
  }
  return 0;
}

Г клас

#include <stdio.h>

int recurse(int b) {
  if(b > 3000001) {
    return 1;
  }
  return recurse(b + 1);
}

int main() {
  int val;
  scanf("%d", &val);
  int res = recurse(val);

  printf("%d", res);
  return 0;
}
#include <stdio.h>
#include "other.c"

#ifdef PE
  #undef PE
#endif

int main() {
  char sho[10] = "asdf";
  printf("%d\n", aplusb(5,6));
  printf("%s\n", PE);
  return 0;
}

other.c:

#define PE sho

int aplusb(int a, int b){
  return a + b;
}