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

The Archive Base Latest Questions

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

for some reason when running a program it refuses to enter a for loop,

  • 0

for some reason when running a program it refuses to enter a for loop, and rather just hangs.

main()
{      

    char *buffer;
    int chunk_offset, current_chunk_number, total_chunks;
    int filelen;

    filelen = ReadFileintoBuffer( buffer);  
        printf("file read \n");                             // error break point 1


    int events = filelen/eventlen;      // number of 512 + 2 32 bit events events with timecode

    int sp = 0;
    int i,j;
    int toterror[25];
    printf("file of length %d has %d events \n", filelen, events);
    printf(" i = %d \n", i);
    for( i = 0; i < events; i++)
    {
        printf("analyzed %d events of %d", i, events);
        sp=0;
        int error[13];

        Analyzeevent(buffer+i*eventlen, error);

        if(error[0])
        {
            sp = 12;
        }
        for( j =1; j < 13; j++)
        {
            toterror[j+sp] += error[j];
        }

    }
    printf("post for loop");
    Printerrs(toterror, events);
    exit(0);

}  

It prints everything down to i = (9727988 in this particular case), then nothing. it all just stops. any idea what happened? i learned c++ and programming in c is very strange and awkward for me right now. compiler doesnt throw up any warnings or anything

thank you for your help in advance.

edit: for ring0 heres the code to ReadFileintoBuffer:

int ReadFileintoBuffer( char *buffer)
{ 
    int filelen;
    char text[200];
    printf("Input File:  " );
    scanf( "%s" ,text);
    FILE *file = 0;

    int i;


    //Open file
    file = fopen(text, "rb");
    if (!file)
    {
            fprintf(stderr, "Unable to open file \n");
        exit(0);

    }

    //Get file length
    fseek(file, 0, SEEK_END);               // find the end of the file
    filelen=ftell(file);                    // set the current pointer (currently at end from above) as file length
    fseek(file, 0, SEEK_SET);               // set pointer back to beginning of file

    //Allocate memory
    buffer=(char *)malloc(filelen+1);
    if (!buffer)
    {
        fprintf(stderr, "Memory error! \n");
                                fclose(file);
        return;
    }

    //Read file contents into buffer
    fread(buffer, filelen, 1, file);
    fclose(file);                           // clse the file, all in buffer now
    return filelen;
}
  • 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-27T23:35:05+00:00Added an answer on May 27, 2026 at 11:35 pm

    You may be getting some buffering issues with printf. Try adding a \n to the print inside the for loop. (Like you have in some of the earlier prints)

    It may be executing all the code but you aren’t seeing the printed result.

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

Sidebar

Related Questions

For some reason I'm having trouble getting my program to run a while loop.
For some reason on my application when running on some configuration of hard disk
For some unknown reason I'm running into a problem when passing a variable to
For some reason, in IE8, javascript is not running unless I reload the page
For some reason, when I press Capture while my device is connected and running
For some reason, I can't get this program to work. I've had other CS
All, I am running into an issue using JTextArea and JScrollPane. For some reason
for some reason my server that uses socket.io is not working properly. The program
For some reason I never see this done. Is there a reason why not?
For some reason when I attempt to make a request to an Ajax.net web

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.