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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:11:31+00:00 2026-06-15T11:11:31+00:00

In my program I have to print a general journal with data coming from

  • 0

In my program I have to print a general journal with data coming from 2 files, ‘accounts.dat’ and ‘transactions.dat’

accounts.dat has:

1000:first
2000:second
3000:hello

transactions.dat has

1000:first:d:1000.000000
2000:second:c:1500.000000
3000:hello:d:1000.000000

So basically the same data except transactions has 2 more.

When I checked my read function which scans the file data and inputs it into arrays that are in the program, they’re there but when I call the generaljournal function to print it in a specific format, the general journal does not acknowledge the files that are scanned into my arrays.

the function is:

void generaljournal(int accounts[MAX], int accounts3[MAX], char debcred[MAX], double amount[MAX], char accname[MAX][MAXSTRING], char transname[MAX][MAXSTRING], int *totalinput) {

int i = 0;

printf ("\n");
printf ("\t\t\tGeneral Journal\n");
printf ("Account  Description                          Debit      Credit\n");
printf ("-------  ------------------------------  ----------  ----------\n");


for (i = 0; i < *totalinput; i++)
{
    printf ("   %d", accounts[i]);


    if (debcred[i] == 'd')
    {
        printf ("  %-35s", transname[i]);
        printf ("%.2lf\n", amount[i]);
    }


    else if (debcred[i] == 'c')
    {
        printf ("  %-47s", transname[i]);
        printf ("%.2lf\n", amount[i]);
    }

}

printf ("\n");

}

All the arrays that are called has the data in the arrays but aren’t being printed when I call the general journal function. I call the read function in my main but even if I put the

read(accounts, accounts3, debcred, amount, accname, transname);

In my general journal function it still doesn’t do anything.
What the output SHOULD look like is something like

Account     Description     Debit     Credit
1000        first           1000.000
2000        second                    1500.00
3000        hello           1000.00

Instead it prints just the shell of (accounts, description, debit, credit) with no values underneath.

Does anyone know why it’s not accepting the values in the arrays when I scanned it all from the files in my read function? If more information is needed i’ll supply. My read function is:

void read (int accounts[MAX], int accounts3[MAX], char debcred[MAX], double amount[MAX], char accname[MAX][MAXSTRING], char transname[MAX][MAXSTRING]) {

FILE *fp1 = NULL;
FILE *fp2 = NULL;

fp1 = fopen("accounts.dat", "r");
fp2 = fopen("transactions.dat", "r");

int h = 0;



if (fp1 != NULL) // READING THE FILE
{
    while(fscanf(fp1, "%d", &accounts[h]) != EOF)
    {

            fgetc(fp1);
            fscanf(fp1, "%30[^\n]", &accname[h]);
            h++;
    }

    fclose(fp1);
}
else
    printf ("Failed to open file\n");



if (fp2 != NULL) // READING THE FILE
{
    int j = 0;
    while(fscanf(fp2, "%d", &accounts3[j]) != EOF)
    {
        fgetc(fp2);
        fscanf(fp2, "%30[^:]", &transname[j]);
        fgetc(fp2);
        fscanf(fp2, "%c", &debcred[j]);
        fgetc(fp2);
        fscanf(fp2, "%lf", &amount[j]);
        j++;
    }

    fclose(fp2);
}
else
    printf ("Failed to open file\n");

}
  • 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-15T11:11:33+00:00Added an answer on June 15, 2026 at 11:11 am

    Maybe the value of *totalinput is 0

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

Sidebar

Related Questions

I would have expected the following C# program to only print EOF! once I
I have a program which prints a multi-page document. The first page is pre-printed
I have a program developed and it has a single entry point. A Try
I have one application that prints messages from Test.exe in console .My java program
I have program that has a variable that should never change. However, somehow, it
I have a program that monitors certain files for change. As soon as the
Consider this simple program. The program has two files: File Vehicle.java class Vehicle {
At some point of my program I have an atom formed by what previously
I have a command line program that prints out a report such as: I
I have a simple python program that I'd like to daemonize. Since the point

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.