Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9204245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:39:58+00:00 2026-06-17T23:39:58+00:00

In some code that I read, there was an initializing statement like this char

  • 0

In some code that I read, there was an initializing statement like this

char *array[]= { "something1", "something2", "something3" };

What does this mean, and what does that pointer actually point to?
How is that allocated in memory, and how can I access every element and every character of an element in that array ?

— Edited —
and please what is the difference in this example between
char array[3];
and
char *array[3];
— Edited —

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:39:59+00:00Added an answer on June 17, 2026 at 11:39 pm

    what that means ?

    It’s initializing an array of strings (char *) with three values (three pointers to null-terminating strings)

    and what that pointer points to ?

    It should point to the first element in the char* array

    how is that allocated in memory ?

    It will allocate enough memory to store the three strings followed by null-terminators, as well as the three pointers to those strings:

    array --> pointer to three sequential memory addresses
    
    array[0] --> something1{\0}
    array[1] --> something2{\0}
    array[2] --> something3{\0}
    

    Note that the strings may not necessarily be in sequential memory

    and how can I access every element

    if by “element” you mean the string, you can loop though the pointers:

    for(int i=0; i<3; i++)
    {
        char* element = array[i];
    }
    

    and every character of an element in that array

    well, you could access the chars using array syntax (element[i]) but I would recommend using the C string functions for safety (so you don’t have to worry about accessing memory outside the range of the string)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read some XSLT examples and found that code: <xsl:apply-template select=@*|node()/> What does that
I have some code that looks something like this: <head runat="server"> <script type="text/javascript"> var
We have some code that looks like this: class Serializer { public: template<class Type>
I have html code that looks roughly like this: <div id=id1> <div id=id2> <p>some
I have some code that looks something like this: d = {'foo': True, 'bar':
Got some code that is not mine and its producing this warning atm: iehtmlwin.cpp(264)
I have read that there is some overhead to using C++ exceptions for exception
I am trying to write some code that will open a file, read its
I am trying to read some code that I did not write. In the
I have some code that does (independent) operations on a bunch of Python Imaging

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.