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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:16:34+00:00 2026-06-14T00:16:34+00:00

I am getting this error on the last line of the code, as I

  • 0

I am getting this error on the last line of the code, as I am trying to read data from an extra.txt file. Records are read properly from an input.txt but not sure why it is throwing error for extra file. Thanks!

typedef struct {
    char* fname;
    char* lname;
    int id;
    int age;
} data;

typedef struct {
    data** array;
    int len;
    int cap;
}vector;

vector* vector_read(FILE* in_file)
{
    int i;
    vector *v = (vector*)malloc(sizeof(vector));
    fscanf(in_file,"%d",&v->len);
    if(in_file=NULL)
     {
       return NULL;
     }
    printf("%d",v->len);
    data** array = (data**)malloc(sizeof(data*)*(v->len));
    v->array = array;
    data *temp;

   for(i=0;i<(v->len);i++)
   {    
     temp = data_read(in_file);        
     v->array[i] = temp;
   }

return v;
}

    vector *v = vector_read(input);
    printf( "initial state of vector v\n");
    vector_print(v);
    vector *v_add = vector_read(extra); 

EDIT:

extra.txt has records in this fashion:

4

Barak Obama 101 50  
Joe Biden 102 55  
Joe Plumber 10293 45  
Wayne Gretzky 99 56

and input.txt

1

Aaaa
Aooo
1
20
  • 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-14T00:16:35+00:00Added an answer on June 14, 2026 at 12:16 am

    Your code needs go inside a function.

    For example like this:

    int read_input_and_extra(FILE * input, FILE * extra)
    {
      vector *v = vector_read(input);
      if (!v)
        return -1;
    
      printf( "initial state of vector v\n");
      vector_print(v);
    
      vector *v_add = vector_read(extra); 
      if (!v_add)
        return -2;
    
      return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run the code below and I keep getting this error back:
I am trying to plot a pie chart from a .txt file with data-set
I´m getting this error while trying to commit to a svn repository: svn: MKACTIVITY
Keep getting this error after inserting a subdatasheet into a query and trying to
Am getting this error for my code: Undefined symbols for architecture x86_64: _spendDollars, referenced
I am trying to read in a simple flat file, it has 738,627 records
I'm trying to define a simply Fraction class And I'm getting this error: python
I am getting this error: Msg 201, Level 16, State 4, Procedure NewEmployee, Line
I`m getting this error: java.util.vector cannot be cast to javax.collections.observablelist When trying to populate
I'm getting this error message trying to use PHP Mailer. Please let me know

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.