Memory allocation problem !!!
-
Hello Sir,
char **argv
argv = (char**)malloc(3*sizeof(char*));
argv[1] = (char*)malloc((20)*sizeof(char));
argv[1] = "D:\\Input.jpg";When I debug my application
argv[1] - 0x00000000 CXX0030:Error Expression cannot be evaluated
What i am mistaking above code ..please replay thanks -
Hello Sir,
char **argv
argv = (char**)malloc(3*sizeof(char*));
argv[1] = (char*)malloc((20)*sizeof(char));
argv[1] = "D:\\Input.jpg";When I debug my application
argv[1] - 0x00000000 CXX0030:Error Expression cannot be evaluated
What i am mistaking above code ..please replay thankschar **argv = NULL;
argv = (char**)malloc(3*sizeof(char*));
argv[1] = (char*)malloc((20)*sizeof(char));
argv[1] = "D:\\Input.jpg";
cout<Its working guy.
-
char **argv = NULL;
argv = (char**)malloc(3*sizeof(char*));
argv[1] = (char*)malloc((20)*sizeof(char));
argv[1] = "D:\\Input.jpg";
cout<Its working guy.
thanks for your replay ..sir
char **argv = NULL;
argv = (char**)malloc(3*sizeof(char*));
argv[0] = argv1[0];
argv[1] = (char*)malloc((20)*sizeof(char));
argv[1] = "D:\\Input.jpg";
::MessageBox(0,(LPWSTR)argv[1],(LPWSTR)"test",0);the output of message box string is showing unknown square box .. i dont know why sir ..please replay thanks
-
thanks for your replay ..sir
char **argv = NULL;
argv = (char**)malloc(3*sizeof(char*));
argv[0] = argv1[0];
argv[1] = (char*)malloc((20)*sizeof(char));
argv[1] = "D:\\Input.jpg";
::MessageBox(0,(LPWSTR)argv[1],(LPWSTR)"test",0);the output of message box string is showing unknown square box .. i dont know why sir ..please replay thanks
char **argv = NULL;
argv = (char**)malloc(3*sizeof(char*));
//argv[0] = argv1[0];
argv[1] = (char*)malloc((20)*sizeof(char));
argv[1] = "D:\\Input.jpg";
::MessageBox(0,(LPCTSTR)argv[1],(LPCTSTR)"test" ,0); -
char **argv = NULL;
argv = (char**)malloc(3*sizeof(char*));
//argv[0] = argv1[0];
argv[1] = (char*)malloc((20)*sizeof(char));
argv[1] = "D:\\Input.jpg";
::MessageBox(0,(LPCTSTR)argv[1],(LPCTSTR)"test" ,0);PrafullaShirke27 wrote:
argv[1] = (char*)malloc((20)*sizeof(char)); argv[1] = "D:\\Input.jpg";
What's the purpose of the above sequence? [added] I reckon it was already in the OP post. [/added] :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
PrafullaShirke27 wrote:
argv[1] = (char*)malloc((20)*sizeof(char)); argv[1] = "D:\\Input.jpg";
What's the purpose of the above sequence? [added] I reckon it was already in the OP post. [/added] :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]What is OP post?
-
thanks for your replay ..sir
char **argv = NULL;
argv = (char**)malloc(3*sizeof(char*));
argv[0] = argv1[0];
argv[1] = (char*)malloc((20)*sizeof(char));
argv[1] = "D:\\Input.jpg";
::MessageBox(0,(LPWSTR)argv[1],(LPWSTR)"test",0);the output of message box string is showing unknown square box .. i dont know why sir ..please replay thanks
raju_Code wrote:
char **argv = NULL; argv = (char**)malloc(3*sizeof(char*)); argv[0] = argv1[0]; argv[1] = (char*)malloc((20)*sizeof(char)); argv[1] = "D:\\Input.jpg"; ::MessageBox(0,(LPWSTR)argv[1],(LPWSTR)"test",0);
What a mess! Try:
TCHAR * argv[3];
// here you may need a conversion if argv1 is an ANSI string
argv[1] = _T("D:\\Input.jpg");
::MessageBox(0, argv[1],_T("test"),MB_OK);:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
What is OP post?
O
riginalP
oster's message. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Hello Sir,
char **argv
argv = (char**)malloc(3*sizeof(char*));
argv[1] = (char*)malloc((20)*sizeof(char));
argv[1] = "D:\\Input.jpg";When I debug my application
argv[1] - 0x00000000 CXX0030:Error Expression cannot be evaluated
What i am mistaking above code ..please replay thanksraju_Code wrote:
argv[1] = (char*)malloc((20)*sizeof(char)); argv[1] = "D:\\Input.jpg";
Why bother allocating memory if you are just going to reassign the pointer?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons