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. intialisation of charecter array

intialisation of charecter array

Scheduled Pinned Locked Moved C / C++ / MFC
questiondata-structures
6 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.
  • C Offline
    C Offline
    Coder Block
    wrote on last edited by
    #1

    hi guys, If i create one character array of some size like, char* TempArray[10]; how do i intialise it???

    L R T 3 Replies Last reply
    0
    • C Coder Block

      hi guys, If i create one character array of some size like, char* TempArray[10]; how do i intialise it???

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      That is not a character array, it's an array of pointers. You need something like:

      char foo[10] = "string";
      // or
      char* foo = "string";

      Note: Your signature is too big.

      Use the best guess

      C 1 Reply Last reply
      0
      • L Lost User

        That is not a character array, it's an array of pointers. You need something like:

        char foo[10] = "string";
        // or
        char* foo = "string";

        Note: Your signature is too big.

        Use the best guess

        C Offline
        C Offline
        Coder Block
        wrote on last edited by
        #3

        nop i need array of charecter pointer?? not normal pointer above example that you have given is normal character string i need array of characters string. And i will change my sign;.

        L 1 Reply Last reply
        0
        • C Coder Block

          nop i need array of charecter pointer?? not normal pointer above example that you have given is normal character string i need array of characters string. And i will change my sign;.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Coder Block wrote:

          nop i need array of charecter pointer??

          That's not what your original question asked for.

          char* foo[10] =
          {
          { "string1" },
          { "string2" },
          { "string3" },
          // ...
          NULL // use to signify end of array if length is not known at compile time.
          };

          And your signature is still too big; use the standard font size.

          Use the best guess

          1 Reply Last reply
          0
          • C Coder Block

            hi guys, If i create one character array of some size like, char* TempArray[10]; how do i intialise it???

            R Offline
            R Offline
            rxylinux
            wrote on last edited by
            #5

            you can initialise the array just like this char *TempArray[10] = {NULL};

            1 Reply Last reply
            0
            • C Coder Block

              hi guys, If i create one character array of some size like, char* TempArray[10]; how do i intialise it???

              T Offline
              T Offline
              ThatsAlok
              wrote on last edited by
              #6

              Coder Block wrote:

              char* TempArray[10];

              you have initialize every array item individually like this char * temp[10]={"1","2"......};

              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
              Never mind - my own stupidity is the source of every "problem" - Mixture

              cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

              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