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...

Which of the following is a free and open format for providing efficient streaming and manipulation of high-quality digital multimedia including audio, video, text (subtitles), and metadata?

A. .mpg B. .vp8 C. .avi D. .oog

Computer Science & Information Technology

To select several contiguous columns, you:

A) click the header of the first column, then double-click the header of the last column. B) click the header of the first column, then right-click the header of the last column. C) click the header of the first column, press and hold Shift, and click the header of the last column. D) click the header of the first column, press and hold Ctrl, and click the header of the last column.

Computer Science & Information Technology

The ____ of Visual Studio 2017 contains buttons for commands that are frequently used, such as Open Project, Save, Cut, Copy, Paste, and Undo.

A. menu bar B. Standard toolbar C. Toolbox D. Properties window

Computer Science & Information Technology

Give the coordinates of point F. Determine the quadrant or axis where the point is located. Answer Quadrant I, Quadrant II, Quadrant III, Quadrant IV, origin, x-axis, or y-axis.__________

What will be an ideal response?

Computer Science & Information Technology