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

  • Home
  • SEARCH
  • 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 7761755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:13:06+00:00 2026-06-01T14:13:06+00:00

I want (or need) to do something along the lines of char **my_array =

  • 0

I want (or need) to do something along the lines of

char **my_array = malloc(1000*64);
strcpy(arr[0], "test");

While I know that arr[0] isn’t pointing to a separate piece of allocated memory, I thought one should be able to copy a string into it like this (yet it segs). This works

arr[0] = "test";

However that is not going to work, for my actual goal is to do this in shared memory.

shm_array = shmget(IPC_PRIVATE, 1000 * 64, IPC_CREAT | 0644);
my_array = (char**) shmat(shm_array, (void**)0, 0);

Actually my question could be rephrased to: “How do you create an array of strings in shared memory?”. I tried creating 1000 separate “string” shared memory segments, but apart of that it did not work it also seems wrong. Moreover, I thought one should simply be able to write into a big shared memory segment using relative pointer offsets.

  • 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-01T14:13:08+00:00Added an answer on June 1, 2026 at 2:13 pm

    You could just create one single piece of memory and write to specific offsets:

    char * const buf = malloc(HUGE);
    
    strcpy(buf + offset1, "hello");
    strcpy(buf + offset2, "world");
    

    It’d probably be better to use strncpy and pass a size of HUGE - offset along to make sure you don’t run over the end. Managing the offsets is your own responsibility. Or you can use strncat, if efficiency doesn’t matter so much.

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

Sidebar

Related Questions

I want to ditch my current editor. I feel I need something else. That
Potentially embarrassing question, but there is obviously something I'm missing that I want/need to
Hi I have an li element that will have something along the lines of
I want to be able to do something along the lines of this: __
I want to notify an user using Chrome browser. I need something powerful like
I want to export a XtraGrid as an image. Pratically i need something like
i want something like this the user enter a website link i need check
For example, I want to draw something directly to an UIView. I need an
for iOS 5.0 using ARC, here is something I want to implement and need
I've gotten used to the idea that if I want/need to use alpha-trans PNGs

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.