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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:37:35+00:00 2026-05-27T08:37:35+00:00

LIST *list; list = createList(); FILE *file = fopen(test.txt,r); char line[50]; char* token; while(fgets(line,sizeof(line),file))

  • 0
LIST *list;
list = createList();
FILE *file = fopen("test.txt","r");
char line[50];
char* token;

while(fgets(line,sizeof(line),file))
{
    token = strtok(line," ,:=");
    while (token != NULL)
    {
       printf("\n%s",token);
       token = strtok(NULL," ,:=");
    }
}

this piece of code separates the lines in my file into tokens correctly.
now , I want to insert them into a linked list. But adding addNode function inside the while loop :

while (tp != NULL)
{
     printf ("\n%s",token);
     token = strtok (NULL, " ,:=");
     addNode(li,&token);
}

does not work while inserting.

the addNode function is : (from the given library)

int addNode (LIST* pList, void* dataInPtr)
{
    bool found;
    bool success;
    NODE* pPre;
    NODE* pLoc;

    found = _search (pList, &pPre, &pLoc, dataInPtr);
    if (found)
       return (+1);

    success = _insert (pList, pPre, dataInPtr);
    if (!success)
       return (-1);
    return (0);
} 

Anyone has an idea about this?

  • 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-27T08:37:35+00:00Added an answer on May 27, 2026 at 8:37 am

    This is possibly the problem:

     addNode(li,&token); /* Passing char**, not char* */
    

    change to:

     addNode(li,token);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new in ubuntu 12.04 LTS . I want to create list file
I have a program that takes a list of names from a file and
I have to download and parse some file and put create list of object
i dont know why the list returned is NULL , this is the code:
I'm trying to create a singly linked list from an input text file for
I'm basically trying to create a linked list from a text file and add
main function: int main() { if((ban_file = open_file(banned_ips.txt)) == NULL) goto exit; ban_lst =
I'm looking for way to create list view as like in IOS with pinned
I am using the following css to create list items with a chckerboard background
I've got an array of values that i'm using to create list items that

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.