I wrote this a little while ago... I know i need to add a file check so overwrite does not occur but I am interested in learning to write clearer and less amatuer code. Any serious note would help...
this program creates a file with an input name, saves text, and opens the file after being created/saved in that order just to simplify error checking...
C++ saver
------------------------------------
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
char something[256];
char text[256];
char text1[256];
char filetext[256];
char filename[256];
string line;
string write1 = "write";
string open1 = "open";
int main(){
cout << "Command... write?\n";
cin.getline (text, 256);
if (text == write1){
cout << "\nEnter text to be saved.\n";
cin.getline (filetext, 256);
}
cout << "\n";
cout << "Enter filename...\n";
cin.getline (filename, 256);
ofstream myfile;
myfile.open (filename);
myfile << filetext;
myfile.close();
cout << "\nCommand... open?\n";
cin.getline (text1, 256);
if (text1 == open1){
ifstream myfile(filename);
getline (myfile, line);
cout << "\n" << line << "\n\n";
myfile.close();
}
system("PAUSE");
return 0;
}
------------------------------------------
thank you