Problem about how to choice Mulit-file to output from File Date O/I

This is a discussion on Problem about how to choice Mulit-file to output from File Date O/I within the C Programming forums, part of the General Programming Boards category; Problem about how to choice Mulit(or 2+ more file)-file to output from File Date O/I in C programming. Thank!...

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    1

    Question Problem about how to choice Mulit-file to output from File Date O/I

    Problem about how to choice Mulit(or 2+ more file)-file to output from File Date O/I in C programming.
    Thank!

  2. #2
    Fear the Reaper...
    Join Date
    Aug 2005
    Location
    Toronto, Ontario, Canada
    Posts
    625
    That's not a question. Not even close.
    Teacher: "You connect with Internet Explorer, but what is your browser? You know, Yahoo, Webcrawler...?" It's great to see the educational system moving in the right direction

  3. #3
    The C eater *munch*
    Join Date
    Oct 2006
    Posts
    101
    >Problem about how to choose ?Multi(or 2+ more file)-file to output from File >Data O/I in C programming.
    >Thank[b]'s!
    typos?
    fopen, fscanf

  4. #4
    Registered User S0n1C's Avatar
    Join Date
    Oct 2006
    Posts
    12
    If I understand what your trying to say, your talking about having more then one file to output data to. All you have to do is declare more then one file pointer, for example:

    Code:
    /*File Pointers*/
    FILE *output1;     //pointer 1
    FILE *output2;    //pointer 2
    
    /*Variables*/
    int num1 = 12;    //num for file1
    int num2 = 67;    //num for file2
    
    /*open files*/
    output1 = fopen("c:\\ouput1.txt","w");         //You can put what
    output2 = fopen("c:\\output2.txt","w");       //ever the the file location
    
    /*Write nums to file1*/
    fprintf(output1,"%d", num1);
    
    /*Write nums to file2*/
    fprintf(output2, "%d", num2);
    If you have to 2 files, and what to input them to your program, this is an example, its pretty much the same as above.

    Code:
    /*File Pointers*/
    FILE *input1;     //pointer 1
    FILE *input2;    //pointer 2
    
    /*Variables*/
    int num1;    //num from file1
    int num2;    //num from file2
    
    /*open files*/
    input1 = fopen("c:\\input1.txt","r");   /*open file1*/
    input2 = fopen("c:\\input2.txt","r");   /*open file2*/
    
    /*Set num1 to files in input1*/
    fscanf(input1,"%d", &num1);
    fgetc(input1);
    
    /*Set num2 to files in input2*/
    fscanf(input2,"%d", &num2);
    fgetc(input2);
    
    /*Display numbers from File1*/
    printf("File1\t%d", num1);
    printf("\nFile2\t%d",num2);
    I hope that answers your question a little, if you need anything further, ask, and i'll send you i'd be glad to answer it, or point you in the right direction

    Hope it helped;
    S0n1C!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Straight Insertion Sort function problem
    By StaticKyle in forum C++ Programming
    Replies: 6
    Last Post: 05-12-2008, 05:03 AM
  2. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 05:54 PM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 09:39 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  5. problem with output
    By Garfield in forum C Programming
    Replies: 2
    Last Post: 11-18-2001, 08:34 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21