How to close file in C++?
-
Yet another "problem" got me stumped. To verify "networking" I use system call such as
system("vim /etc/hosts");
It does the job, however, I cannot figure out how to close the file. The standard "vim" way is "Esc :q!" , and it is unclear which character should be "send" via standard console and which ones after responses from vim. Either manually (cin) or as a string starting with "Esc". Cheers
-
Yet another "problem" got me stumped. To verify "networking" I use system call such as
system("vim /etc/hosts");
It does the job, however, I cannot figure out how to close the file. The standard "vim" way is "Esc :q!" , and it is unclear which character should be "send" via standard console and which ones after responses from vim. Either manually (cin) or as a string starting with "Esc". Cheers
-
Yet another "problem" got me stumped. To verify "networking" I use system call such as
system("vim /etc/hosts");
It does the job, however, I cannot figure out how to close the file. The standard "vim" way is "Esc :q!" , and it is unclear which character should be "send" via standard console and which ones after responses from vim. Either manually (cin) or as a string starting with "Esc". Cheers
-
What kind of verification does
vim
? I am asking such a question because, I believe, while it is not straightforward closingvim
, there could be better alternatives to 'verify networking'.I wondered about that too: if the point is just to verify that you can access a certain file across a network file path, then trying to open it with fstream::open() should do the job. Whereas, emulating console input that is supposed to be passed into an external process would be kind of tricky, to say the least...
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
-
What kind of verification does
vim
? I am asking such a question because, I believe, while it is not straightforward closingvim
, there could be better alternatives to 'verify networking'.