By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,515 Members | 1,772 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,515 IT Pros & Developers. It's quick & easy.

problems with system()

P: n/a
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

May 31 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Jens Kleine wrote:
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
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
May 31 '07 #2

P: n/a
Victor Bazarov <v.********@comAcast.netwrote:
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.

May 31 '07 #3

P: n/a
Jens Kleine wrote:
Victor Bazarov <v.********@comAcast.netwrote:
>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.
Conflict? Like what?
May 31 '07 #4

P: n/a
On May 31, 4:53 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
Jens Kleine wrote:
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.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Jun 1 '07 #5

P: n/a
James Kanze wrote:
[..]
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
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 1 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.