I have the following code:
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
int main() {
int data = 0;
char *byte = (char *)malloc(sizeof(char)*1000000000);
byte[999999999] = 'a';
printf("%c",byte[999999999]);
scanf("%d",&data);
return 0;
}
Looking at memory before the program starts and before the scanf I would expect the memory to increase of 1 GB. Why isn't this happening?
Edit: I added
byte[999999999] = 'a';
printf("%c",byte[999999999]);
The program outputs a
.