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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Define character pointer

Define character pointer

Scheduled Pinned Locked Moved C / C++ / MFC
debugginghelpquestion
15 Posts 6 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.
  • M Mazdak

    I have even problem with somwthing like: char* attachbody= new char[]; :confused: Mazy No sig. available now.

    N Offline
    N Offline
    Nick Parker
    wrote on last edited by
    #6

    Mazdak wrote: char* attachbody= new char[]; This will not work, you have to specify the size of the char array inside of the array brackets. -Nick Parker

    M 1 Reply Last reply
    0
    • N Nick Parker

      Mazdak wrote: char* attachbody= new char[]; This will not work, you have to specify the size of the char array inside of the array brackets. -Nick Parker

      M Offline
      M Offline
      Mazdak
      wrote on last edited by
      #7

      Oh,yes. The strange problem is that I have no problem in one line,but some lines later,these problem happned. :( Mazy No sig. available now.

      N 1 Reply Last reply
      0
      • M Mazdak

        Oh,yes. The strange problem is that I have no problem in one line,but some lines later,these problem happned. :( Mazy No sig. available now.

        N Offline
        N Offline
        Nick Parker
        wrote on last edited by
        #8

        Mazdak wrote: The strange problem is that I have no problem in one line,but some lines later,these problem happned If you have already declared char *pszIn, you can delete it, set it to NULL and then reassign it if you need a different size with the same variable name. -Nick Parker

        M 1 Reply Last reply
        0
        • N Nick Parker

          Mazdak wrote: The strange problem is that I have no problem in one line,but some lines later,these problem happned If you have already declared char *pszIn, you can delete it, set it to NULL and then reassign it if you need a different size with the same variable name. -Nick Parker

          M Offline
          M Offline
          Mazdak
          wrote on last edited by
          #9

          Well, thanks Nick for the help. I'll try it too. :) Mazy No sig. available now.

          1 Reply Last reply
          0
          • M Mazdak

            I don't know why I define any new character pointer in my program.When ever I do it when debugger reach to it,I recieve unhandled error,in line like this:

            char *pszIn = new char[size];

            Any idea? This happend not from beginig.It happend after some place. Mazy No sig. available now.

            N Offline
            N Offline
            Neville Franks
            wrote on last edited by
            #10

            Is size big enough for the string being placed in pszIn and in particular does it include room for the \0 C string terminator? Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com

            1 Reply Last reply
            0
            • M Mazdak

              I don't know why I define any new character pointer in my program.When ever I do it when debugger reach to it,I recieve unhandled error,in line like this:

              char *pszIn = new char[size];

              Any idea? This happend not from beginig.It happend after some place. Mazy No sig. available now.

              B Offline
              B Offline
              Beer
              wrote on last edited by
              #11

              I think CString is for you. hey

              C M 2 Replies Last reply
              0
              • B Beer

                I think CString is for you. hey

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #12

                Or std::string. It's for everyone. char * are unnecessary most of the time, people use them because C++ is almost always poorly taught by old C hackers. Christian NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma Anonymous wrote: OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window. I think you are a good candidate for Visual Basic. - Nemanja Trifunovic

                1 Reply Last reply
                0
                • M Mazdak

                  I don't know why I define any new character pointer in my program.When ever I do it when debugger reach to it,I recieve unhandled error,in line like this:

                  char *pszIn = new char[size];

                  Any idea? This happend not from beginig.It happend after some place. Mazy No sig. available now.

                  T Offline
                  T Offline
                  Toni78
                  wrote on last edited by
                  #13

                  This would happen to me when I had memory leaks. The program would run just fine and then unpredictably it would crash whenever I would allocate memory. Try to use a constant instead of "size" variable. Try different values and if your program runs fine and never crashes then you must have a memory leak. // Afterall I realized that even my comment lines have bugs

                  1 Reply Last reply
                  0
                  • B Beer

                    I think CString is for you. hey

                    M Offline
                    M Offline
                    Mazdak
                    wrote on last edited by
                    #14

                    Beer wrote: I think CString is for you. I'm using C++. Mazy No sig. available now.

                    B 1 Reply Last reply
                    0
                    • M Mazdak

                      Beer wrote: I think CString is for you. I'm using C++. Mazy No sig. available now.

                      B Offline
                      B Offline
                      Beer
                      wrote on last edited by
                      #15

                      You can use std::string as Christian suggested then, I assume you mean you can't use CString because you are using Borland CPP, or linux CPP with KDevelop or something. I suggested CString because this forum is supposed to be for Visual C++. I also assume that if you meant you don't want to use MFC, that you'd have posted something along the lines of "I don't wanna use MFC" CString is readily available to Visual C++ CPP projects through the MFC headers Mazdak wrote: Beer wrote: I think CString is for you. I'm using C++. Mazy No sig. available now. hey

                      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