Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Problem reading file in BMP convertion (http://www.go4expert.com/forums/reading-file-bmp-convertion-t12632/)

luiceur 1Aug2008 22:06

Problem reading file in BMP convertion
 
I am trying to convert a bmp file to ppm file.In order to do that:
1-I am reading the bitmap file
2-Order the new aux file
In step 2 is where i got the problem,i can't read the same!! Please,could anyone tell me what the hell i am doing wrong???

Code:

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <fstream>
#define MAXW 1024
#define MAXH 1024


using namespace std;

void loadBMP(char* infile,char* outfile);
void putOrder(char* infile);
int numberOflines(char* infile);


int main (int argc, char* argv[] ) {


        int BMPw;
        int BMPh;

        loadBMP(argv[1], argv[2]);
        putOrder(argv[2]);
        return 0;
}

void loadBMP(char* infile,char* outfile) {
   
    ifstream in ;
    ofstream out;
    int width;
    int height;

    //Open File
    in.open(infile);
    out.open(outfile);
   
    in.seekg(54,ios::beg);
   
    while(!in.eof()){

        out << in.get() << endl;
    }
    in.close();
    out.close();
}   
void putOrder(char* infile){
   
    ifstream inf;
    ofstream outf;
    int nLines;
    string t;

    inf.open(infile);
    outf.open("outOrder");

    inf.seekg(10,ios::beg);
    while (!inf.eof()){
      outf << inf.get() << endl;
    }
    inf.close();
    outf.close();
}



All times are GMT +5.5. The time now is 05:44.