If the code actually runs it is only because of the way that the compiler lays down the stack and/or what the exact code did just before the first method was called.
In the method the pointer is considered to be non-initialized but because it is a pointer that was created on the stack it will have a value, whatever was in the memory that the stack is using at that point. Thus correctly stated 'garbage'.
I am trying to make a global 2D array using vectors, but I am having some trouble in doing so. Below code is a small part of my project where I need to make a global 2D array whose size has to be passed through a command line. I am passing row and column as command line arguments.
You declare your vector as a global, but the values of row and col will be zero when it is created. Make it a local variable and let your ESSolver object manage it. Or better still make it a member of the ESSolver class.
The array needs to be dynamically allocated. This is done using the new operator. I usually prepend an "m_" to member variable names so I know that is what they are. The array will be allocated in the class constructor and released in the destructor.
int * m_array;
cls( int length ); // constructor
~cls(); // destructorvoid print_array();
cls::cls( int length ) // constructor
m_length = length;
m_array = new int[length];
cls::~cls() // destructor
delete  m_array;
m_array = nullptr;
int main(int argc, char *argv)
int length = atoi( argv );
cls obj( length );
Did you pass a valid line number to it like 0? If you pass it -1 "the return value is the number of unselected characters in the lines that contain selected characters" according to the documentation.
You will have to do the length limiting of each line yourself because LimitText and SetLimitText define how many total characters the control can accept, not just on one line.
Also, to get the number of pixels per character you should call GetTextExtent which is a member of the CDC class. The typical way is to generate a string with all upper and lower case letters, call GetTextExtent with that string, and then divide the resulting width by the string length to get an average for each character. There are lots of examples that show how to do this.
mycsize.cx represents the number of pixels per character originally I multiplied by 8 figuring 8 characters per line but I ended up multiplying by 10 to get 8 characters to fit
asidgprs and asidacess are 2 multiline edit controls in the Dialog
I ended doing a lot tweeking wit this to get it to the right size
Is there a reason you need to use multi-line edit controls of a fixed width? It seems like an array of single line edit controls might do what you need and it is easier to limit the length of data in them.