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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:28:07+00:00 2026-06-12T06:28:07+00:00

This is a really fascinating error to me, because literally an hour ago this

  • 0

This is a really fascinating error to me, because literally an hour ago this code was working just fine, but now it’s not.

Essentially what is happening is that the first character of first ‘block’ of the following row is being appended as the last character of the final ‘block’

Whereby ‘block’ I mean the string that is held within that row/col.

For example, let’s say that the array is supposed to be something like

1,2,3,Hello
4,5,6,Wonder

It is being read in as

1,2,3,Hello4,
6,Wonder, , 

Here’s the logic that I’ve been using. I really don’t know what changed, so any advice would be excellent.

tableFile = fopen(argv[4], "r");


//pulling the table data from the file
char tableArray[30][50][256];
char c;
int i=0, j=0, k=0;
while(c != EOF){

    c = fgetc(tableFile);

    switch(c)
    {
        case ',':
            tableArray[i][j++][k]='\0';
            k=0;
            break;
        case '\n':
            tableArray[i++][j][k]='\0';
            j=0;
            k=0;
            break;
        case '\r':
            break;
        case EOF:
            break;
        default:
            tableArray[i][j][k++] = c;
            break;
    }

} //end file transfer

//Just to display, ignore magic numbers as (mostly) irrelevant
int a, b;

for (a = 0; a < 20; a++)
{
    for (b = 0; b < 47; b++)
    {
        printf ("%s", tableArray[a][b]);
        if (b<46)
            printf (", ");

    }
    printf ("\n");
}

fclose(tableFile);
  • 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-12T06:28:08+00:00Added an answer on June 12, 2026 at 6:28 am

    This is really due to the comments immediately below my original post. But, as disgusting and poor coding form as it is… this is what solved it consistently, not that I’m proud of it… and still open to ideas:

    tableFile = fopen(argv[4], "r");
    
    //pulling the table data from the file, lazy magic numbers here... 
    char tableArray[30][50][256];
    char c;
    int i=0, j=0, k=0;
    
    memset(tableArray, 0, sizeof(tableArray));
    while(c != EOF){
    
        c = fgetc(tableFile);
    
        switch(c)
        {
            case ',':
                tableArray[i][j++][k]='\0';
                k=0;
                break;
            case '\n':
                tableArray[i++][j][k]='\0';
                j=0;
                k=0;
                break;
            case '\r':
                tableArray[i++][j][k]='\0';
                j=0;
                k=0;
                break;
            case EOF:
                tableArray[i][j][k] = '\0';
                break;
            default:
                tableArray[i][j][k++] = c;
                break;
        }
    
    } //end file transfer
    
    /* //Only relevant for displaying the tableArray
    int a, b;
    
    for (a = 0; a < 20; a++)
    {
        for (b = 0; b < 47; b++)
        {
            printf ("%s", tableArray[a][b]);
            if (b<46)
                printf (", ");
    
        }
        printf ("\n");
    }
     */
    
    fclose(tableFile);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I came across this (really) simple program a while ago. It just outputs the
This really should be easy, but I just can't work it out myself, the
This really should not be difficult but damned if I can figure it out...
This really should not be this complicated, but can't figure it out. Have several
i build this really simple script but i did not work. Can somebody tell
I'm getting this really annoying error. I've been working on it for days, as
Im getting this really annoying error in when I run this Haskell code. For
This really seems like a bug to me, but perhaps some databinding gurus can
This really shouldn't be hard, I just can't figure out how to do it.
This really puzzled for hours, I searched all over the internet, but got no

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.