Запустите прогамму (исходный код приведен в конце документа) и ответьте на вопросы



Download 15,9 Kb.
Sana31.12.2021
Hajmi15,9 Kb.
#264281
Bog'liq
Вопросы


Запустите прогамму (исходный код приведен в конце документа) и ответьте на вопросы

I. For each of the 17 addresses printed, choose the correct label: STATIC / STACK / HEAP.

global var max is at ___________

param m is at ___________

char *abc is at ___________which points to ___________

char *abc2 is at ___________which points to ___________

local var x is at ___________

local var y is at ___________which points to ___________

static var z is at ___________

void *p1 is at ___________which points to ___________

void *p2 is at ___________which points to ___________

void *p3 is at ___________which points to ___________

function fun is at ___________



II.

What is the lowest STATIC address printed in part I? ___________

What is the highest STATIC address printed in part I? ___________

What is the lowest STACK address printed in part I? ___________

What is the highest STACK address printed in part I? ___________

What is the lowest HEAP address printed in part I? ___________

What is the highest HEAP address printed in part I? ___________

III.

There cannot be any overlap between HEAP / STACK / STATIC address ranges. Did you have any overlap between HEAP / STACK / STATIC addresses (Yes/No)? ___________

-----------------

Source code of the progra:

// gcc -Wall heap.c -o heap

// ./heap

# include

# include

# include

int max = 100;

static void fun(double m) {

double x = 3;

double *y = &x;

static double z = 300;

char *abc = "abc";

char *abc2 = strdup(abc);

void *p1 = malloc(10);

void *p2 = (void *) "abcdef";

void *p3 = (void *) &x;

printf("global var max m is at %p\n", &max);

printf("param m is at %p\n", &m);

printf("char *abc is at %p whicj points to %p\n", &abc, abc);

printf("char *abc2 is at %p\n which points to %p\n", &abc2, abc2);

printf("local var x is at %p\n", &x);

printf("local var y is at %p which points to %p\n", &y, y);

printf("static var z is at %p\n", &z);

printf("void *pl is at %p which points to %p\n", &p1, p1);

printf("void *p2 is at %p which points to %p\n", &p2, p2);

printf("void *p3 is at %p which points to %p\n", &p3, p3);

printf("function fun is at %p\n", &fun);

}

int main(int argc, char *argv[]) {



fun(4);

return 0;



}
Download 15,9 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish