'Why does nCurses (C++) block System() function?
I don't know if it is a thing just for me but I need to open a file with notepad on windows in a C++ program. I use at the same time ncurses for the pseudo-GUI but I noticed that all the "system()" calls don't work at all
void test() {
cout<<"\n\nTEST FUNCTION\n";
system("file.xml");
}
does open the file but if I use
void test() {
cout<<"\n\nTEST FUNCTION\n";
initscr();
system("file.xml");
endwin();
}
It doesn't work. With Windows' GetLastError() it gives me error 87 (invalid parameter) but for opening a file the command used is just the file name itself
Can someone please help me?
Solution 1:[1]
ncurses on Windows could refer to different environments:
- Cygwin (where opening an xml file probably does not work, since
systemusesshrather thancmd) - MinGW (which would use
cmd) - WSL (undocumented like most of WSL, but probably like Cygwin)
With MinGW, ncurses switches the console mode by creating a screen buffer (analogous to xterm's alternate screen), which allows it to address cells on the visible screen. Doing that entails changing the inputs for that window. cmd would in that case change its behavior regarding file associations.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Thomas Dickey |
