hello,
how do i put the output of another program into a variable of my c-programm?
i have tried it this way, but it does not work:
does anyone know?Code:system(StringOfAskingTheOtherProgram) scanf("%s", strMyVariable);
hello,
how do i put the output of another program into a variable of my c-programm?
i have tried it this way, but it does not work:
does anyone know?Code:system(StringOfAskingTheOtherProgram) scanf("%s", strMyVariable);
Yah you can do that did you heard of send message technique in Windows.
I dont know if this will be useful or not but you can #include the code and use the variable(which is your output) using extern keyword.
HOPE YOU UNDERSTAND.......
By associating with wise people you will become wise yourself
It's fine to celebrate success but it is more important to heed the lessons of failure
We've got to put a lot of money into changing behavior
PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
IDE- Microsoft Visual Studio 2008 Express Edition
I'm using Linux.
Maybe it would work with unix-pipes? i don't know how.
Pipes indeed. This is an example:
This program takes the output of the linux command "ls" in "r"-mode (this is a file-mode, meaning 'read') and puts the output in upper case. All the magic is in the popen()Code:#include <stdlib.h> #include <stdio.h> #include <ctype.h> int main(){ int c; FILE * ifp; ifp = popen("ls", "r"); while ((c = getc(ifp)) != EOF) putchar(toupper(c)); pclose(ifp); return 0; }
Hope this helps.