Then
system()
is the function you need.It is simple, only the command has to be passed and it will return 0 if command successfuly executed, 1 otherwise.
syntax:
int system(const char *command);
As system function is declared in stdlib.h, it can be considered a C function. But in C++, stdlib.h is merged into the std namespace and is located in the cstdlib .
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdlib> | |
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
int returnCode = system("nm -C -S -n mylib.so > libSymbols.log"); | |
if (returnCode == 0) { | |
cout << "Command executed successfully." << endl; | |
} | |
else { | |
cout << "Command execution failed" << returnCode << endl; | |
} | |
return 0; | |
} |
No comments:
Post a Comment