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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:55:04+00:00 2026-06-04T13:55:04+00:00

void echoFileA(const char* iPath,const char* oPath) { FILE* iFile; FILE* oFile; iFile = fopen(iPath,rb);

  • 0
void echoFileA(const char* iPath,const char* oPath)
{
    FILE* iFile;
    FILE* oFile;

    iFile = fopen(iPath,"rb");
    oFile = fopen(oPath,"wb");

    while(iFile)    
        fputc(fgetc(iFile),oFile);

    fclose(iFile);
    fclose(oFile);
}

The procedure was written purely for fun, I know that there are covenient , premade functions for copying files in the every OS API libriaries. Back to the topic- why the loop condition is always true, even if the EOF was reached a long time ago?
I’ve checked that I’ve passed the correct parameters to this function in the testing program.

  • 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-04T13:55:05+00:00Added an answer on June 4, 2026 at 1:55 pm

    The body of your loop …

       fputc(fgetc(iFile),oFile);
    

    … does nothing to change the condition of the loop, so it will run forever.

    Instead try something like …

    int c;
    while((c = fgetc(iFile)) != EOF) 
       fputc(c, oFile);
    

    The loop will end once you hit the end of the input file.

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

Sidebar

Related Questions

void getS(char *fileName){ FILE *src; if((src = fopen(fileName, r)) == NULL){ printf(%s %s %s,
void max_min(sqlite3 *db) { //call back********* int i, ncols; sqlite3_stmt *stmt; char *sql; const
void expand_combinations(const char *remaining_string, string const & s, int rema in_depth) { if(remain_depth==0) {
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { xmlParseChunk(context, (const char *)[data bytes], [data length], 0);
void openUpNow(FILE *x, FILE *y) { x = fopen(xwhatever, r); y = fopen(ywhatever, r);
void display(char * str){ printf(%s: Missing file\n, str); } int main(int argc, char **argv)
void foo(const char* s) { } foo(bar); Where is the memory bar deallocated? What
void test() { unsigned char c; c = (~0)>>1 ; printf(c is %u\n,c); }
void say(char msg[]) { // using pointer to print out the first char of
void return_input (void) { char array[30]; gets (array); printf(%s\n, array); } After compiling it

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.