basic filling in c++

please give me feedback :)
https://www.facebook.com/invigorating.arslaan

#include <fstream>
#include <iostream>
using namespace std;
void printToFile(char array[100], int x);
void readFile();
int main () {
        printToFile("Introduction to computer Science (A & B)",2);
        readFile();
        return 0;
}

void printToFile(char array[100], int x){
        ofstream outfile;
        outfile.open ("test.txt", ofstream::out | ofstream::app);
        if(outfile){
                outfile<<array;
                outfile<<"   ";
                outfile<<x;
                outfile<<"\n";
                outfile.close();
        }
}

void readFile(){
        char array[100]={0};
        int x;
        char var;
        ifstream infile;
        infile.open ("test.txt", ifstream::in );
        if(infile){
                while(!infile.eof()){
                        infile.getline(array, 100,'     ');
                        cout<<array<<" ";
                        if(!infile.eof()){
                                infile>>x;
                                cout<<x<<endl;
                        }
                }
                infile.close();
        } 

Comments

Popular Posts