system call as variable
i want to use system bit as a input of my c program. i wrote a code:
Quote:
can you people plz help me? |
I take it that you don't want the i686 result to appear on the standard console, the way it is doing?
You want to pipe the output from uname into your program. Instead of using the system call, use popen. man popen will get you going, but it looks like this: Code:
#include <stdio.h> |
ok but then also while i am including it like:
#include <stdio.h> #include <stdlib.h> #include <unistd.h> int main() { FILE *stream; char sys[5],*sysptr; sysptr = &sys[0]; sys[4] = 0x0; stream=popen("/bin/uname -m","r"); fread(sysptr,1,4,stream); pclose(stream); printf("%s\n",sysptr); if (sysptr == i686) printf("32bit\n"); else printf("64bit\n") } its showing error: un2.c:16: error: ‘i686’ undeclared (first use in this function) i am not getting the reason of this error. plz help |
and if i do
if (sysptr == "i686") { printf("32bit\n"); } else { printf("64bit\n"); } } then also its not giving desired result!!! will you plz check? |
You need to declare the variable i686.
Beyond that, the boolean equality won't work; you need to look up strncmp. Is this homework? |
no dear....i am a research student!! problem is i do fortran generally...not much familiar with C!! but since bitwise operation is much more efficient in C , i thought i will better do it as C....
|
All times are GMT -5. The time now is 09:04 PM. |