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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:57:03+00:00 2026-05-27T16:57:03+00:00

I have a struct in my main.h but when I try to allocate memory

  • 0

I have a struct in my main.h but when I try to allocate memory for the 3D array in the struct, I get the following compiler error.

    'text' has no member named 'list'

Now, I only get this for the 3D array the the other variables in the struct.

main.h

#define MAX_WORD 100

typedef struct textTag {
   char name[100];
   char  ***list;
   int words;
}text;

main.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "main.h"

void createArray(FILE *file, text *checkTexts, int fileCount,  int size){
   int i, n, wordCount, sections, rest;
   FILE *textFile;
   text localText;
   char fileName[MAX_WORD + 30];

   readFileNames(file, checkTexts);

   for(i = 0; i < fileCount; i++){
      localText = checkTexts[i];

      strcpy(fileName, "./testFolder/");
      strcat(fileName, checkTexts[i].name);
      openFile(&textFile, fileName);

      checkTexts[i].words = countWords(textFile);

      sections = (wordCount / size);
      rest = wordCount % size;
      checkTexts[i].list = malloc(sections * sizeof(char **)); //Compile error here

      for(n = 0; n < sections; n++){
         checkTexts[i].list[n] = malloc(size * sizeof(char *)); //Compile error here
      }

      checkTexts[i].list[sections] = malloc(rest * sizeof(char*)); //Compile error here

      readFileContent(textFile,checkTexts[i].list, size); //Compile error here

   }

}
  • 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-27T16:57:04+00:00Added an answer on May 27, 2026 at 4:57 pm

    Like I said in the comment.

    Fixed the problem

    It was a stupid mistake be my self, where i had accidently opened the wrong main.h file, so I was editing a file for an other project, so the struct i was using did indeed not have en member list.

    But thanks for trying to help me.

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

Sidebar

Related Questions

I try to save a simpel struct (vector3) in the sqlite3_bind_blob but I have
Code snippet to follow. I have a struct (example code has class, tried both,
i have some question. I try this code and recieve Segmentation fault error: #include
I want to have an variable-length array contained within a structure, but am having
I try to compile the following code with clang (version 3.0), but it gives
Ok so I have struct like this typedef struct { float x; float y;
Suppose I have: struct Magic { Magic(Foo* foo); Magic(Bar* bar); }; Is there a
In my driver's file_operations structure, I have: struct file_operations Fops = { read: device_read,
I'm using LLVM-clang on Linux. Suppose in foo.cpp I have: struct Foo { int
I have a struct defined like follows as part of an object. I'm trying

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.