Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 9th, 2008, 06:25 AM
rudra
Guest
 
Posts: n/a
Default system call as variabe

plz forgive me to put a C problem here; but the point is general!
i have written a code::
#include <stdio.h>
#include <stdlib.h>
int main()
{
int sys;
int i686;
sys=system("/bin/uname -m");
//printf ("%d",sys);
if (sys==i686){
printf("the syst. 32 bit");
}
else
printf("64but");
}
where i want the output of "system("/bin/uname -m")" as the variable
sys.....to find the machine structure.this procedure is not quite
working. can you people suggest me some way?
  #2  
Old July 9th, 2008, 06:45 AM
Ian Collins
Guest
 
Posts: n/a
Default Re: system call as variabe

rudra wrote:
Quote:
plz forgive me to put a C problem here; but the point is general!
Please don't multi-post on Usenet, answered elsewhere.

--
Ian Collins.
  #3  
Old July 9th, 2008, 06:05 PM
Sherman Pendley
Guest
 
Posts: n/a
Default Re: system call as variabe

rudra <bnrj.rudra@gmail.comwrites:
Quote:
plz forgive me to put a C problem here; but the point is general!
i have written a code::
#include <stdio.h>
#include <stdlib.h>
#include <cstdio>
#include <cstdlib>
Quote:
int main()
{
int sys;
int i686;
sys=system("/bin/uname -m");
//printf ("%d",sys);
if (sys==i686){
What are you comparing here? The i686 variable hasn't been initialized
to anything.
Quote:
printf("the syst. 32 bit");
}
else
printf("64but");
}
where i want the output of "system("/bin/uname -m")" as the variable
sys.....to find the machine structure.this procedure is not quite
working.
Not working, or not doing what you expect? System() is supposed to
return the called app's exit code. If /bin/uname is successfully
launched and doesn't crash, that should be 0.
Quote:
can you people suggest me some way?
I tried to find a standards-based solution to this, but for the life
of me I couldn't find a C++ streams equivalent to C's popen()
function. The closest I could find was to construct a Boost.Iostream
with a file descriptor opened with popen().

Did I miss something?

sherm--

--
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles