C++ examples for File Stream:Text File
Converting Between Tabs and Spaces in a Text File
#include <iostream> #include <fstream> #include <cstdlib> using namespace std; int main(int argc, char** argv) { ifstream in("main.cpp"); ofstream out("target.cpp"); if (!in || !out) return(EXIT_FAILURE); char c;//from w ww . j av a 2 s . c om while (in.get(c)) { if (c == '\t') out << " "; // 3 spaces else out << c; } out.close(); if (out) return(EXIT_SUCCESS); else return(EXIT_FAILURE); }