Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Memory allocation problem !!!

Memory allocation problem !!!

Scheduled Pinned Locked Moved C / C++ / MFC
helpdebuggingperformance
9 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Game point
    wrote on last edited by
    #1

    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

    P D 2 Replies Last reply
    0
    • G Game point

      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

      P Offline
      P Offline
      PrafullaShirke27
      wrote on last edited by
      #2

      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.

      G 1 Reply Last reply
      0
      • P PrafullaShirke27

        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.

        G Offline
        G Offline
        Game point
        wrote on last edited by
        #3

        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

        P CPalliniC 2 Replies Last reply
        0
        • G Game point

          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

          P Offline
          P Offline
          PrafullaShirke27
          wrote on last edited by
          #4

          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);

          CPalliniC 1 Reply Last reply
          0
          • P PrafullaShirke27

            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);

            CPalliniC Offline
            CPalliniC Offline
            CPallini
            wrote on last edited by
            #5

            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]

            In testa che avete, signor di Ceprano?

            P 1 Reply Last reply
            0
            • CPalliniC CPallini

              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]

              P Offline
              P Offline
              PrafullaShirke27
              wrote on last edited by
              #6

              What is OP post?

              CPalliniC 1 Reply Last reply
              0
              • G Game point

                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

                CPalliniC Offline
                CPalliniC Offline
                CPallini
                wrote on last edited by
                #7

                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]

                In testa che avete, signor di Ceprano?

                1 Reply Last reply
                0
                • P PrafullaShirke27

                  What is OP post?

                  CPalliniC Offline
                  CPalliniC Offline
                  CPallini
                  wrote on last edited by
                  #8

                  Original Poster'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]

                  In testa che avete, signor di Ceprano?

                  1 Reply Last reply
                  0
                  • G Game point

                    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

                    D Offline
                    D Offline
                    David Crow
                    wrote on last edited by
                    #9

                    raju_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

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups