problems with system()

J

Jens Kleine

Hi, I've been having some problems with system calls.

When I create a simple file like this
int main(int argc, char *argv[])
{
int x;
printf("Checking if processor is available...");
if(system(NULL))
puts ("Ok");
else
exit (1);
x = system("date");
printf("The value returned was: %d.\n", x);

return 0;
}

everything works fine and all the functions I enter are called and executed.
But when I include the same code into a larger programme (this is where I
need to call another function multiple times) system() doesn't execute the
function and just returns some value like 1280 or 32768.
Does anybody know what the problem could be?

Kind regards,
Jens
 
V

Victor Bazarov

Jens said:
Hi, I've been having some problems with system calls.

When I create a simple file like this
int main(int argc, char *argv[])
{
int x;
printf("Checking if processor is available...");
if(system(NULL))
puts ("Ok");
else
exit (1);
x = system("date");
printf("The value returned was: %d.\n", x);

return 0;
}

everything works fine and all the functions I enter are called and
executed. But when I include the same code into a larger programme
(this is where I need to call another function multiple times)
system() doesn't execute the function and just returns some value
like 1280 or 32768. Does anybody know what the problem could be?

Yes, somebody in the newsgroup dedicated to your compiler or your OS
should definitely be able to help you. Calls to 'system' are
implementation- and platform-specific. Their side effects and the
return value meanings are not defined by the Standard if the argument
is not a null pointer.

V
 
J

Jens Kleine

Victor Bazarov said:
Yes, somebody in the newsgroup dedicated to your compiler or your OS
should definitely be able to help you. Calls to 'system' are
implementation- and platform-specific. Their side effects and the
return value meanings are not defined by the Standard if the argument
is not a null pointer.

I know but I hoped there was some known c++ dependent conflict with the call
of other functions.
 
J

James Kanze

Jens said:
Hi, I've been having some problems with system calls.
When I create a simple file like this
int main(int argc, char *argv[])
{
int x;
printf("Checking if processor is available...");
if(system(NULL))
puts ("Ok");
else
exit (1);
x = system("date");
printf("The value returned was: %d.\n", x);
return 0;
}
everything works fine and all the functions I enter are called and
executed. But when I include the same code into a larger programme
(this is where I need to call another function multiple times)
system() doesn't execute the function and just returns some value
like 1280 or 32768. Does anybody know what the problem could be?
Yes, somebody in the newsgroup dedicated to your compiler or your OS
should definitely be able to help you.

I wouldn't be sure of it. A short summary of his posting is
"Here's some code that works, but I've got some different code
which doesn't. What's wrong with the code I'm not showing you?"

I know that even if the platform were Unix (which I know very,
very well), I couldn't do more than guess (problem with $PATH?)
with the small amount of data given.
Calls to 'system' are implementation- and platform-specific.
Their side effects and the return value meanings are not
defined by the Standard if the argument is not a null pointer.

Maybe in the code he's not showing us, the argument is a null
pointer:).

You're right, of course, that he really is asking in the wrong
place. But regardless of where he asks, he's going to have to
give a bit more information if he wants an answer.
 
V

Victor Bazarov

James said:
[..]
You're right, of course, that he really is asking in the wrong
place. But regardless of where he asks, he's going to have to
give a bit more information if he wants an answer.

The point is that in a proper place folks would know how to lead
him to providing the right information by asking the right
questions (like about $PATH variable or some such)...

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top