Is it possible to write a function that returns a pointer? What possible problem could the programmer encounter if the address of a function’s local variable (i.e., pointer) was returned to the calling function?

What will be an ideal response?


Sure, it is possible to return a pointer. If a local variable’s address is returned to the calling function, the variable goes out of scope. The pointer will be pointing at a section of memory that is no longer valid. If another function is called, and new variables are placed on the stack, that pointer would then be pointing at that data.

Computer Science & Information Technology

You might also like to view...

Write an isEmpty method for a stack implemented with an array. You may assume that there is an integer variable named count that keeps track of the number of elements in the stack.

What will be an ideal response?

Computer Science & Information Technology

Other than a DoS attack, what could cause a company’s webserver crash?

A. Normal expected traffic B. Encrypting traffic C. Referrals from large sites D. Hashing traffic

Computer Science & Information Technology

Panels are _________________________ when they display only their tab.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

A while loop tests its condition before performing its statements making it a(n) ____ loop.

A. pretest B. posttest C. failsafe D. infinite

Computer Science & Information Technology