devxlogo

Returning a Value

Returning a Value

Question:
When executing a system call, how can I return a value back? My program will already return a value back.

Example:

String blah = system("some command");

Is this correct?

Answer:
No, the system() function returns a code that indicates whether the invocation of the command shell was successful (0 indicates success). However, it doesn’t return the status of the program it executes. For that purpose, you need more advanced techniques such as sockets, files, or signals, depending on the platform you’re using.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist