Thread: where is my wrong reading from file and write

  1. #1
    Registered User
    Join Date
    Mar 2014
    Posts
    95

    where is my wrong reading from file and write

    input the in.txt is 1 2 4 5
    the result is:6 nonetheless i can't write it on the out.txt
    thank you for all appreciated answers
    Code:
    #include <stdio.h>
    
    void ad( FILE* fptr_in, FILE* fptr_out);
    
    int main(){
    
        FILE *pFile_in;
        FILE *pFile_out;
    
            pFile_in = fopen ("in.txt","r+");
        pFile_out = fopen ("out.txt","w+");
    
            fprintf (pFile_out, "%s\n","ad:");
        ad(pFile_in, pFile_out);
    
        return 0;
    }
    void ad( FILE* fptr_in, FILE* fptr_out){
    
    
    
    
        fptr_out=fopen("out.txt","w");
        fprintf(fptr_out,"%d",(2+3));
        fclose(fptr_out);
    
    }
    Last edited by Ph0x; 09-29-2014 at 02:02 PM.

  2. #2
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    How To Ask Questions The Smart Way

    You need to be more detailed with your problem.

    What is the program supposed to do?
    What is the input supposed to be?
    What is the output supposed to be?
    What is the actual output?

    And please try to ask your question more clearly.

    It would also help to post a small sample of the input file, when one is required for the program.

  3. #3
    Registered User
    Join Date
    Mar 2014
    Posts
    95
    Quote Originally Posted by Matticus View Post
    How To Ask Questions The Smart Way

    You need to be more detailed with your problem.

    What is the program supposed to do?
    What is the input supposed to be?
    What is the output supposed to be?
    What is the actual output?

    And please try to ask your question more clearly.

    It would also help to post a small sample of the input file, when one is required for the program.
    i fixed

  4. #4
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Quote Originally Posted by Ph0x View Post
    i fixed
    Hardly. You're still missing a lot of the information I suggested, such as what the program is trying to accomplish.

    I did notice something though. Answer me two things:

    1. What is line 11 doing?
    2. What is line 37 doing?

  5. #5
    Registered User
    Join Date
    Mar 2014
    Posts
    95
    Quote Originally Posted by Matticus View Post
    Hardly. You're still missing a lot of the information I suggested, such as what the program is trying to accomplish.

    I did notice something though. Answer me two things:

    1. What is line 11 doing?
    2. What is line 37 doing?
    open two times thank you

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. wrong reading or binary file
    By yahzee in forum C Programming
    Replies: 2
    Last Post: 01-15-2013, 06:18 AM
  2. Replies: 2
    Last Post: 11-01-2011, 01:57 PM
  3. Replies: 6
    Last Post: 11-11-2006, 02:10 PM
  4. Replies: 2
    Last Post: 09-13-2006, 01:14 PM
  5. Whats wrong with my file reading program?
    By Alphabird32 in forum C++ Programming
    Replies: 1
    Last Post: 09-08-2002, 03:19 AM