> struct _stack {
//fill in here
char* ele;
int size;
int top;
};
Stack create(int maxStackSize) {
//Create an empty stack whose maximum size is maxStackSize
Stack mathstack;
mathstack->size = maxStackSize;
mathstack->top = -1;
mathstack->ele = (char*)malloc(maxStackSize * sizeof(char));
return mathstack;
}
When you write the code like this, you receive a warning that you are using memory 'mathstack' that has not been initialized at runtime. So if you initialize 'mathstack=0', it doesn't work with the warning that you're referencing the NULL pointer 'mathstack'. Can you tell me what the problem is? It's not working because it's not created.ㅠ<
c
Errors (errors) and warnings are different.
The warning does not necessarily need to be fixed in the learning code. An execution file is created even if there is a warning.
However, if there is an error, you need to fix the error. If there is an error, the executable file is not generated.
When you simply declare and use a variable (including a class variable), a warning appears that it uses uninitialized memory.
If there is no processing code for the Mallock function failing to operate when memory is allocated to the Mallock function, a warning message appears warning that it is referencing back.
Neither of the above alerts is a problem for execution. I think there is an error in another code.
It is separate from the above, but there is a problem with the code below.
Stack mathstack;
mathstack->size = maxStackSize;
In the code above, mathstack was declared a general variable The arrow operator (->) approaches the internal variable, which is used to access the internal variable of the pointer variable. The second line should use a point operator, not a pointer operator, as shown below.
mathstack.size = maxStackSize;
524 Uncaught (inpromise) Error on Electron: An object could not be cloned
679 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
543 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
546 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.