| | |
how to make utilize of system( ) function
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Sep 2006
Posts: 1
Reputation:
Solved Threads: 0
Hi All,
I am using system function to decrypt an encrypted file, But it's taking too much of time, as a result of file access
i want to know how to store the output of system( ) function into local variables instead of a file.
Code goes like this.
sprintf(syscommand,"des -D -k %c%c credit0_e credit0",keys[i],keys[j]);
ret1=system(syscommand);
my professor gave an hint saying we can use pipes(|) to redirect output to local variables. I don't know how to do that please help me
I am using system function to decrypt an encrypted file, But it's taking too much of time, as a result of file access
i want to know how to store the output of system( ) function into local variables instead of a file.
Code goes like this.
sprintf(syscommand,"des -D -k %c%c credit0_e credit0",keys[i],keys[j]);
ret1=system(syscommand);
my professor gave an hint saying we can use pipes(|) to redirect output to local variables. I don't know how to do that please help me
Your professor sounds like he's leading you up the garden path - the system() function takes one argument (a const char*) and returns an int, which, in all cases i'm aware of, is purely an indicator for whether or not the call was successful (0 for success, and non-zero for failure). The option of storing the output in a text file sounds like the best one by far.
Last edited by Bench; Sep 7th, 2006 at 8:45 pm.
¿umop apisdn upside down? Its not really all that difficult -- here is an explaination of popen() and and example program. BTW you don't use system() with popen(), but call whatever program you want directly
C Syntax (Toggle Plain Text)
char syscommand[BUFSIZ]; char inbuf[BUFSIZ]; sprintf(syscommand,"des -D -k %c%c credit0_e credit0",keys[i],keys[j]); if ((ptr = popen(syscommand, "r")) != NULL) while (fgets(inbuf, BUFSIZ, ptr) != NULL) (void) printf("%s", buf); (void) pclose(ptr);
Last edited by Ancient Dragon; Sep 7th, 2006 at 11:35 pm.
![]() |
Similar Threads
- c++ system() function?? (C++)
- system function in c++ (C++)
- problem with system() function... (C++)
- System function, output to file (C++)
- System() Function: Info on uses & Description (C++)
Other Threads in the C Forum
- Previous Thread: string to long and string to double in c
- Next Thread: Where does the string gets stored?
| Thread Tools | Search this Thread |
#include adobe ansi api append array arrays asterisks binarysearch changingto char character cm copyimagefile cprogramme creafecopyofanytypeoffileinc csyntax database directory dynamic execv feet fgets file fork framework frequency function getlasterror givemetehcodez global grade gtkgcurlcompiling hacking hardware highest histogram include incrementoperators infiniteloop input interest kernel keyboard kilometer license linked linkedlist linux linuxsegmentationfault list lists locate logical_drives looping loopinsideloop. lowest match matrix meter microsoft motherboard mqqueue number odf opensource overwrite owf pattern pdf performance pointer posix probleminc process program programming radix recursion recv repetition research reversing scripting segmentationfault sequential socket socketprograming standard string systemcall testing threads turboc unix user voidmain() wab windows.h windowsapi






