Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSC215 Homework Homework 06 Due date: Oct 30, 2016.

Similar presentations


Presentation on theme: "CSC215 Homework Homework 06 Due date: Oct 30, 2016."— Presentation transcript:

1 CSC215 Homework Homework 06 Due date: Oct 30, 2016

2 Question 1 : Redefine each of the following variables using dynamically allocated memory, including the initialization step if any. double temperatures[365]; char q[] = "So many books"; int grades[2][3] = {36, 24, 26, 81, 30, 74}; float zeros[] = {0.0, 0.0, 0.0, 0.0}; Char *names[] = {"Ali", "Omar"}

3 Question 2 : Tell if each of the following code fragments contains an error (compile-time or runtime), specify its type, and correct it. 1) char* p = "Hello world"; printf("%d\n", *p); free(p); 2) int* p = (int*)malloc(10*sizeof(int)); int* q = (int*)realloc(p, 5*sizeof(int)); free(q); 3) int** p = (int*)malloc(2*sizeof(int)); p[0] = (int*)malloc(5*sizeof(int)); p[1] = (int*)malloc(5*sizeof(int));


Download ppt "CSC215 Homework Homework 06 Due date: Oct 30, 2016."

Similar presentations


Ads by Google