CIS 2500 Lecture Notes - Lecture 3: C Dynamic Memory Allocation
76 views2 pages
29 Mar 2017
School
Department
Course
Professor
Document Summary
//this is the creation of a pointer that points to other pointers. //sptr is pointing to a pointer which is pointing to a character[i] //static definition, the memory has space for sptr. //right now it doesn"t point to anything int num = 3; int i; sptr = malloc (sizeof(char *) * num); //we want sptr to point to a location that has room for 3 pointers (num) //sizeof(char*) will be size of pointer and there will be 3 pointers. //malloc returns a pointer to the part of memory that has space for the three sptr. //now we can treat sptr as an array sptr[0] sptr[1] sptr[2] for (i=0; i
Get access
Grade+
$40 USD/m
Billed monthly
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers