Given the following program :
I am supposed to fix the error in the program without adding or changing any variable names or data types. The error I get when I run this program is "c4700: uninitialized local variable 'q' used." I think that this is because in the statement "*q.ptr = 7;" 7 is being assigned to the variable pointed to by ptr, but ptr has not been set to point to another variable yet. I thought of declaring another variable and having ptr point to it, but my instructions say to not add any other variables. How do I fix this without changing or adding any variables?Code:#include <iostream> using namespace std; struct quest { int * ptr; char c; }; int main() { quest q; *q.ptr = 7; q.c = '4'; return 0; }



LinkBack URL
About LinkBacks



