← Back to Question List
C++ Quiz #32
Pointer to Local Variable
This code compiles with a warning but produces unpredictable output. What is the bug?
📄 Code
1#include <iostream>2using namespace std;34int* createNumber() {5 int value = 42;6 return &value;7}89int main() {10 int* p = createNumber();11 cout << *p << endl;12 return 0;13}