#include #include #include #include int main() { std::ifstream inf("test.din",std::ios::in); //Create file streams std::ofstream outf("test.dout",std::ios::out); unsigned int coln = 20; //Max columns unsigned int rown = 10; //Max rows int y = 0; //Current row int x = 0; //Current column char tileset[] = { '!', '@', '#', '$', '%', '^', '&', '*'}; std::vector< std::vector > v; v.resize(coln, std::vector(rown, 0)); //Expand it to the max columns and rows //READING THE INPUT //I'm dealing with a "vector of vectors," so it gets two for loops for each dimension. for(y = 0; y < rown; ++y) //Fills out columns... { for(x = 0; x < coln; ++x) //Fills out rows... { if (!(inf.eof())) //when the file hasn't ended { inf >> v[x][y]; //put file info inside of the vector } else { v[x][y] = 0; //otherwise fill the blank spaces with 0 } //std::cout << v[x][y] << ' '; } //std::cout << std::endl; } //WRITING THE OUTPUT for(y = 0; y < rown; ++y) { for(x = 0; x < coln; ++x) { outf << tileset[v[x][y]] << ' '; } outf << std::endl; } system("PAUSE"); inf.close(); outf.close(); return 0; }