C++

Mar 22, 2016 at 9:57am
hello everybody , i'm now learning c++ and i have this probleme that i'm hopping that you help me with it , you see i want to display a file.txt on the desktop yousing c++ i managed to write my data in the file but what i need is to open the file automatically after the writing is finished , i don't want to open the file on the terminal but i want the file to open on the desktop
Can anyone help me with this pleaaaaaaaaaaaaaaaaaaaaase
Mar 22, 2016 at 10:07am
Last edited on Mar 22, 2016 at 10:07am
Mar 22, 2016 at 10:30am
This link show how to create a file.txt on desktop , what i need is to open it automatically after the writing is finished on the desktop , you see where i'm going here ??
Last edited on Mar 22, 2016 at 10:38am
Mar 22, 2016 at 11:13am
Yes.
You don't want to use existing terminal programs that show the output stream of your program in a GUI window. By "desktop" you don't mean special directory.

By "desktop" you mean GUI. You want to create a GUI window (with all the bells and whistles) within your application that renders the "output content" as text within it.

Am I right?

Qt http://www.qt.io/ is one framework that helps you to do that "relatively" easily. However, the use of any such framework requires rather good command of the programming language (C++). Are you there yet?


One does not need to use GUI frameworks. One can learn esoteric low-level OS-dependent incantations and implement every last detail oneself. There are reasons why that is not a common hobby.
Mar 22, 2016 at 1:01pm
i guess you are talkinking about creating a interface in c++ with Qt , so what i want is not
feasible ??
Mar 22, 2016 at 1:07pm
i don't want to open the file on the terminal but i want the file to open on the desktop
What exactly does that mean? Do you want another application to open the generated file? If so you need system dependent functions like (windows) ShellExecute(...).
Mar 22, 2016 at 3:34pm
i meen when the writing is finished , i don't want to clik on the file to see what is writing , i need to find a commande with c++ that can open the file automatically after the writing is finished is that possible
thanks for your replay :)
Mar 22, 2016 at 4:45pm
Given that you're on windows, you probably have the program notepad.exe on your system.

http://www.cplusplus.com/forum/general/20884/

Do note that using system is, all things considered, a pretty dangerous and uncontrolled way to do this. That thread suggests other functions to use.

I suggest that you get it working with system, as in that thread, and then when the excitement has worn off, learn why using system is dangerous and expensive, and learn how to do it better.
Mar 22, 2016 at 8:25pm
actually i'm working on a raspberry carte not on windows
Mar 24, 2016 at 9:27am
does this command work
system( "notepad.exe myfile.txt" );

??
Mar 24, 2016 at 9:58am
Does "raspberry carte" have "notepad.exe"? I bet not. Does it have some other GUI text editor? Most likely. What editor do you use to write code on raspberry?
Mar 24, 2016 at 10:11am
it has a leafpad , that the one where the writing is
Mar 24, 2016 at 10:33am
Well then you could do worse than trying
system( "leafpad myfile.txt" );

If you're lucky, leafpad will be on the path.

Then, when it's working, you can stop using system and use something better.
Mar 24, 2016 at 11:20am
does this command work
Unlikely, notepad.exe is a windows program.

Again: Describe more precisely what this 'open the file automatically' is supposed to do.
Mar 24, 2016 at 12:59pm
do not know how to open the text file i.e. open it as if I would use my mouse and double click on the text file.
Mar 24, 2016 at 1:26pm
What do you think that the double click on an icon representing a file actually does?
It executes some associated command, usually external program and adds filename as command line argument to the command.

Why the program creating the file should open it for you?
You could have a shell script that first runs your program and then starts leafpad (or whatever).
Mar 24, 2016 at 1:28pm
Topic archived. No new replies allowed.