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 7625927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:15:26+00:00 2026-05-31T05:15:26+00:00

I was wanting to create a 2 dimensional string array that had dimensions string[5][*]

  • 0

I was wanting to create a 2 dimensional string array that had dimensions “string[5][*]” but was having some trouble. I would like to do something like this:

...
for(i = 0;i < 5;i++){
    char* word = ...;
    if(strcmp(word,...)){
        string[i][j] = (char *) malloc(/*size of word*/);
        string[i][j] = word;
        j++;
    }
}

The “string” variable should be of length 5 in the ith direction and should be allowed to grow as much as I need in the jth direction.

I tried doing:

char* string[5];

but that does not seem to work. Please note the above for loop has been simplified and parts might not seem logical.

EDIT:
I am trying to sort a list of strings into 5 categories. So the n-dimentional array should in a sense hold 5 arrays containing an unspecified number of strings (not chars). This I assume is a 3-dimentional char array but was having trouble thinking of how to write it. I want every string[i][j] term to hold a char array. So string[0][0] could equal “cat” or something.

  • 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-05-31T05:15:26+00:00Added an answer on May 31, 2026 at 5:15 am

    Try this.

    char **string;
    string = (char **)(malloc(sizeof(char *) * 5));
    //malloc the string[i] whenever you need to at what ever size is necessary.
    

    Also in your code at the top the problem is each string[i][j] is a char and you can’t malloc for a non pointer. Every string[i] is a char * you have to malloc for that.

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

Sidebar

Related Questions

I am wanting to create an array of arraylist like below: ArrayList<Individual>[] group =
I am wanting to create an application that will monitor the upload/download traffic of
I am wanting to create a program that talks with a Cometd server to
I am wanting to create a VB.Net app that checks a database and then
I've been wanting to create a HUD style loading bar like the SMS app
Hi I am wanting to create in F# a 2D array of size 1000x1000,
I would like to create a widget for use in Django Forms. There is
I'm wanting to create a linear gradient background, that fits the same no matter
I’m having a spot of problem with CakePHP 2.0.2. I’m wanting to create an
Basically I'm wanting to create a GPS system for my car that works offline,

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.