|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
| Sponsored Links |
|
|
|
|||||
|
Seems like I have misunderstood something. You cannot actually use the cmd.exe functions with system()? Hmmm... I tried "PAUSE", and it didn't work either.. I thought you could sort of write a batch script with system() if you wanted to... Do I have to use that Cygwin shell? Is there some linking option for this?
__________________
|
|
|||||
|
If you're running it through "cmd.exe" then you should be able to use both "cls" and "pause". To be honest, I've never heard about the system-function not working. It could be an odd error in your compiler, but I don't think so.
You could try including cstdlib, but it will most likely not work either, as it's, like you say, a runtime error. Last edited by v0id; 07-21-2008 at 03:00 AM. |
|
|||||
|
Okay. This is (exactly) what my dear cmd.exe is telling me:
C:\C++\Projects\SysTest\dist\Debug\Cygwin-Windows>systest.exe sh: PAUSE: command not found C:\C++\Projects\SysTest\dist\Debug\Cygwin-Windows> And this is a simple source code example: Code:
//
// File: sys_main.cc
// Author: me
// Date: Today
// Built to systest.exe
#include <cstdlib> // As usual
#include <cstdio> // As you mentioned...
#include <windows.h> // Why not..
using namespace std; // Probably smart
int main(int argc, char** argv)
{
system("PAUSE");
return (EXIT_SUCCESS);
}
One thing, though: My TrendMicro PcCillin Antivirus reacts on my program, "Unknown software". I just press "Allow" and restart. Disabling my AntiVirus does not help (I just tried). What is happening???
__________________
|
| Sponsored Links |
|
|
|
|||||
|
Your problem is that your parameters to the system-function are directed to sh (of Cygwin). sh does not recognize "pause" nor "cls" as those are not a part of the Cygwin-package (or Unix). I can't say why that is, and I have like I said never experienced it, or heard about others having the same problem.
You could try opening "cmd(.exe)" and compile and run it by-hand, and see what the result then is, without using Cygwin. Last edited by v0id; 07-20-2008 at 10:09 AM. |
|
|||||
|
Just like I thought... "sh" is not cmd.exe at all...
Thanks for the help ![]() I'll try compiling from cmd later EDIT: Now I tried. No way. Still the same. But at least we know that it's not NetBeans' fault, but g++ compiler...
__________________
Last edited by marwex89; 07-20-2008 at 10:28 AM. |
|
|||
|
Try using #include<stdlib.h> instead of #include <cstdlib>. The system() function is defined there too. I'm not sure if it's cross-platform (probably not), but it's worth a try.
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Bash Shell, using wget and awk? | TIGA | General Programming | 0 | 04-11-2008 07:31 PM |
| [Pascal in Delphi]System to system | Krad | Pascal/Delphi | 5 | 12-27-2007 02:35 PM |
| [PHP] Faking Shell Access Through PHP | pranky | PHP Tutorials | 2 | 03-29-2007 07:28 AM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |