• C

commands in the system function

hi, can anybody explain the following line:

system("start cmd.exe /c %s %s -Pipe_Mode:%s %s\n", environmental variable name,filename,name of the named pipe")

i didn't understand what does these /c %s etc here?

or give me a link where i find more about these commands.Thanks in advance.

Who is Participating?
ok then it is all fine...
/c is argument to the executable and %s is string format specifier as in printf

any more questions ?
this is not a valid syntax
>system("start cmd.exe /c %s %s -Pipe_Mode:%s %s\n", environmental variable name,filename,name of the named pipe")

actual proto type is
       int system (const char * string);
it cannot accept more than one argument
Where did you get it from ?

you need to form a single string from all these things (sprintf) and then pass that single string to system

the person who gave it to you perhaps meant that form a command from all these components %s specifies string format specifier
/c is an argument to start cmd.exe
to make the above command work, you need a string like

"start cmd.exe /c aa bb -Pipe_Mode:cc dd"
aa : environmental variable
bb :  name
cc  : filename
dd : name of the named pipe

such string can be obtained using sprintf statement

the right way to invoke this command would be
sprintf ( command, "start cmd.exe /c %s %s -Pipe_Mode:%s %s", ev, n, fn, np );
system (command);

ev holds  : environmental variable
n holds :  name
fn holds  : filename
np holds : name of the named pipe
rukksAuthor Commented:
yes, u r right.
The actual code is as follows:
sprintf(cmdLine, "start cmd.exe /c %s %s -Pipe_Mode:%s %s\n",
                       dat_cmd, geo_file, in_pipe_name, out_pipe_name);
      signal = system(cmdLine);

when i run this code, the command window only momentrarily flashes. system returned zero. I am using named pipes for connecting 2 processes.in_pipe_name, out_pipe_name are the name of these pipes.geo_file contains the file name.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.