c++ system() from variable

#include <iostream>
#include <cstdlib>

int main() {
    std::string command = "ls -l";
    int result = std::system(command.c_str());
    return 0;
}