课程: Complete Guide to C Programming Foundations
今天就学习课程吧!
今天就开通帐号,24,100 门业界名师课程任您挑!
Returning pointers from a function - C教程
课程: Complete Guide to C Programming Foundations
Returning pointers from a function
- [Instructor] When a function returns an address or memory location, the function's data type is a pointer. In this exercise file function, allocate is declared as a character pointer, meaning it returns the address of a character buffer. The function allocates memory to the integer size that's passed. When the allocation fails, the exit function quits the program. Otherwise, the allocated buffers address is returned. As a single value, the address need not be static. In the main function, two pointer variables are declared, A and B. Both are assigned allocated memory returned from the allocate function, buffers of 256 and 512 bytes respectively. Both buffers are freed before the program exits. Run. Both buffers are successfully allocated. The malloc function's argument is really a size T data type, which is the data type used to measure memory. So you could change the declaration from int to size T here. The compiler doesn't throw any errors when the variable is an integer, but this…
内容
-
-
-
-
-
-
-
-
-
-
Understanding pointers3 分钟 23 秒
-
(已锁定)
Using pointers to manipulate data2 分钟 53 秒
-
(已锁定)
Doing pointer math3 分钟 10 秒
-
(已锁定)
Comparing arrays and pointers5 分钟 5 秒
-
(已锁定)
Challenge: Output a string57 秒
-
(已锁定)
Solution: Output a string2 分钟 44 秒
-
(已锁定)
Allocating storage3 分钟 42 秒
-
(已锁定)
Working with a pointer array4 分钟
-
(已锁定)
Using pointers in structures3 分钟 8 秒
-
(已锁定)
Challenge: Allocating structures1 分钟 3 秒
-
(已锁定)
Solution: Allocating structures3 分钟 34 秒
-
(已锁定)
Passing pointers to functions2 分钟 23 秒
-
(已锁定)
Returning pointers from a function2 分钟 31 秒
-
Chapter challenge: Processing input1 分钟 26 秒
-
(已锁定)
Chapter solution: Processing input3 分钟 14 秒
-
-
-
-