Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How can I call system when parameters (filenames, etc.) of the executed command arent known until run time?
How can I call system when parameters (filenames, etc.) of the executed command arent known until run time?
✍: Guest
Just use sprintf (or perhaps strcpy and strcat) to build the command string in a buffer, then call system with that buffer. (Make sure the buffer is allocated with enough space;
Here is a contrived example suggesting how you might build a data file, then sort it (assuming the existence of a sort utility, and Unix- or MS-DOS-style input/output redirection):
char *datafile = "file.dat";
char *sortedfile = "file.sort";
char cmdbuf[50];
FILE *fp = fopen(datafile, "w");
/* ...write to fp to build data file... */
fclose(fp);
sprintf(cmdbuf, "sort < %s > %s", datafile, sortedfile);
system(cmdbuf);
fp = fopen(sortedfile, "r");
/* ...now read sorted data from fp... */
2015-03-18, 1262👍, 0💬
Popular Posts:
Can you explain in brief how can we implement threading ? Private Sub Form1_Load(ByVal sender As Sys...
What's wrong with this initialization? char *p = malloc(10); My compiler is complaining about an ``i...
1. What is normalization. 2. Difference between procedure and functions. 3. Oracle 9i Vs 10g. 4. how...
What is the method to customize columns in DataGrid? Use the template column.
How To Select an Oracle System ID (SID)? - Oracle DBA FAQ - Creating New Database Instance Manually ...