I am trying to open a text file in C++. I dont want the file to be open in the console i want to open the file using one of the text editors like gedit. Can someone show me how to open it using gedit and not in the console.

# include <fstream>
# include <iostream>
# include <string>
# include <ios>
using namespace std;

int main()
{
	fstream filestr;
	filestr.open("text.txt", fstream::in | fstream::out | fstream::app);
	filestr << "This is EPIC looking. \n";
	filestr.close();
	cout<<"Thanks for using this program"<<endl;
	return 0;
}

So what i am looking for is that when i run this program i want the 'text.txt' file to open up in gedit. Thanks for the help

You can use the system() command to open the gedit with the parameter of the file name or you can use some form of spawn().

# include <cstdlib>

int main(){
system("gedit /home/name/Downloads/filename.html");
return 0;

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.