So my problem is that I want users to be able to press enter without the program going to the next line, so the user can use another line of text.(Sorry I don't know a better way to explain it).
Code:
#include "resource.h"
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main(){
string text;
string name;
ofstream test;
string extension;
ifstream view;
char nv;
cout<<"Do you want to view a file or make new one<n/v>?\n";
cin>> nv;
cin.ignore();
if(nv == 'n'){
cout<<"Enter some text\n";
getline(cin, text);
cout<<"enter the file name and path(ex. c:/users/bob/filename)\n";
getline(cin, name);
cout<<"Enter the file extension(if you don't know one put '.txt'\n";
cin>> extension;
string file = name + extension;
test.open(file.c_str());
test<<text;
test.close();
}
if(nv == 'v'){
string open;
cout<<"enter the file name and path(ex. c:/users/bob/filename)\n";
getline(cin, name);
cout<<"Enter the file extension(if you don't know one put '.txt'\n";
cin>> extension;
string file = name + extension;
view.open(file.c_str());
while(getline(view,open))
cout<<open<<endl;
view.close();
}
system("pause");
}