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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:15:59+00:00 2026-06-17T21:15:59+00:00

I’m writing a small C program that loads a linked list with file names

  • 0

I’m writing a small C program that loads a linked list with file names (only). I’m gonna iterate through this list and parse the content of each file name.

When compiling I receive the following error:

main.c: In function 'main':
main.c:25: error: dereferencing pointer to incomplete type
main.c:26: error: dereferencing pointer to incomplete type
make: *** [main.o] Error 1

main.c:

#include <stdio.h>
#include <stdlib.h>

#include "list.h"

int main(int argc, char *argv[])
{
    FNODEPTR node = NULL;

    node = create_filename_list();

    add_filename_node(&node, "file1.txt");
    add_filename_node(&node, "file2.txt");

    //Start Logger
    //Watchdog
    //Warehouse 

    //print_filename_list((struct sFilename *)node);

    while(node!=NULL)
    {
        printf("%s\n",node->chaFilename); //Line 25
        node=node->next; //Line 26
    }

    destroy_filename_list(node);

    exit(0); //0 SUCCESS - 1 FAIL
}

list.c:

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


#include "list.h"

struct sFilename
{
    char chaFilename[25];
    struct sFilename *next;
};

FNODEPTR create_filename_list()
{
    FNODEPTR node = NULL;

    node = (FNODEPTR) malloc(sizeof (struct sFilename)); // Alocando um nó do tipo sFilename

    return node;
}

void add_filename_node(FNODEPTR *fnFilename, char *chaFilename)
{
    FNODEPTR head = *fnFilename; // head recebe o conteúdo de anAction. head aponta para o mesmo endereço que fnFilename
    FNODEPTR newNode;

    newNode = (FNODEPTR) malloc(sizeof (struct sFilename)); // Alocando um nó do tipo sFilename

    strcpy(newNode->chaFilename, chaFilename); // Copiando o conteúdo de chaFilename para newNode->chaFilename.

    newNode->next = head; // next do novo nó aponta para o início da lista (fnFilename)

    head = newNode; //head é igual a newNode. head recebe o endereço de memória de newNode. head está na mesma posição que newNode
    *fnFilename = head; //o conteúdo de anAction é igual a posição de head
}

void print_filename_list(struct sFilename *fnFilename)
{
   if (fnFilename == NULL)
          printf("Nao ha arquivos ftp a serem carregados\n");
   else {
          printf("Os arquivos que serao carregados no T020 sao:\n");
          while (fnFilename != NULL) {
                 printf("\t- %s\n", fnFilename->chaFilename);//fnFilename->chaFilename);
                 fnFilename = (*fnFilename).next;//fnFilename->next;
          }
   }
}

void destroy_filename_list(FNODEPTR fnFilename)
{
    if(fnFilename != NULL)
    {
        free(fnFilename);
    }
}

list.h:

#ifndef LIST_H
#define LIST_H

typedef struct sFilename FNODE;
typedef FNODE *FNODEPTR;

FNODEPTR create_filename_list();
void add_filename_node(FNODEPTR *fnFilename, char *chaFilename);
void remove_filename_node(FNODEPTR *fnFilename);
void print_filename_list(struct sFilename *);
void destroy_filename_list(FNODEPTR fnFilename);

#endif

This list will be passed as reference to other functions (modules) that will parse and load the content into a database. Although I can’t use node->chaFilename to open the files I need to load into the DB.

I got a new problem, when I call parser function passing *node as reference compiler complains the same as above. Example:

parser.c:

//Built-in libs
#include <stdio.h>
#include <stdlib.h>

//Homemade libs
#include "parser.h"
#include "list.h"

int start_parse(FNODEPTR *node)
{
    if(node!=NULL)
    {
        printf("Node is not null\n");
        while(node!=NULL)
        {
            printf("\tNode address %x\n", (unsigned int)node);
            node=node->next;
        };
    }

    return 1;
}

parser.h:

#include "list.h"

#ifndef PARSER_H
#define PARSER_H
int start_parse(FNODEPTR *node);
#endif

GCC output:

gcc -Wall   -c -o parser.o parser.c
parser.c: In function 'start_parse':
parser.c:16: warning: cast from pointer to integer of different size
parser.c:17: error: request for member 'next' in something not a structure or union
make: *** [parser.o] Error 1

Any ideas?

Thanks in advance, and sorry for any English mistake.

  • 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-17T21:16:01+00:00Added an answer on June 17, 2026 at 9:16 pm
    struct sFilename
    {
        char chaFilename[25];
        struct sFilename *next;
    };
    

    This should be defined in list.h file, before the statements:

    typedef struct sFilename FNODE;
    typedef FNODE *FNODEPTR;
    

    EDIT::

    int start_parse(FNODEPTR *node) should rather be int start_parse(FNODEPTR node)

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a small JavaScript validation script that validates inputs based on Regex. I
I want use html5's new tag to play a wav file (currently only supported
I know there's a lot of other questions out there that deal with this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text

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.