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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:20:28+00:00 2026-05-26T11:20:28+00:00

I have a C program where I’m reading in from a file and then

  • 0

I have a C program where I’m reading in from a file and then trying to print it to test it at the moment. The thing i’m having issues is that my const in MAX = 40 and its printing that amount of times. I’ve tried passing a reference to jobcount in the function but I get an error when I add * after int and an & before jobcount when passing it. I appreciate the help, its always quality input on all issues!

#include <stdio.h>

struct record{
  char name[1];
  int arrival_time;
  int job_length;
  int job_priority;
};

const int MAX = 40;

void fileinput(struct record jobs[MAX], int jobcount);
void output(struct record jobs[MAX], int jobcount);
int main(void)
{
  struct record jobs[MAX];
  int jobcount;
  fileinput(jobs,jobcount);
  output(jobs,jobcount);
  return(0);
}

void fileinput(struct record jobs[MAX], int jobcount){
  jobcount = 0;
  FILE *f = fopen("data.dat","r");
  while(fscanf(f, "%s %d %d %d", jobs[jobcount].name, &jobs[jobcount].arrival_time, &jobs[jobcount].job_length, &jobs[jobcount].job_priority) != EOF)
    {
      jobcount++;
      printf("READ IN TEST \n");
    }
}

void output(struct record jobs[MAX], int jobcount){

  int j = 0;
  for(j = 0;j < jobcount; j++)
    {
      printf("%s %d %d %d\n", jobs[j].name, jobs[j].arrival_time, jobs[j].job_length, jobs[j].job_priority);
      printf("FOR LOOP TEST \n");
    }
}

data.dat looks like this

A1 3 3 3
B1 4 4 4
C1 5 5 5
  • 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-26T11:20:29+00:00Added an answer on May 26, 2026 at 11:20 am

    You should not get an error. Probably you might have changed in the forward declaration alone and forgot to change at the definition.

    void fileinput(struct record jobs[MAX], int* jobcount);
    
    fileinput(jobs,&jobcount);
    

    And definition –

    void fileinput(struct record jobs[MAX], int* jobcount) {
        // ....
    }
    

    Since jobcount is a pointer, you need to dereference first to modify/access the value it is pointing at. You need to post the exact error message for further help though.

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

Sidebar

Related Questions

I have a program that generates some standard SQL like SELECT * FROM TEST
I have a program that uses the mt19937 random number generator from boost::random. I
Have a program that's dynamically generating an Excel file and a csv. The excel
I have a program that I'm trying to distribute with py2app. When I run
I have program that has a variable that should never change. However, somehow, it
I have program, that must interact with a console program before my program can
I have program that runs fast enough. I want to see the number of
I have a program that spits out both standard error and standard out, and
I have a program that creates a Windows user account using the NetUserAdd() API
I have a program that spits out an Excel workbook in Excel 2003 XML

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.