title: Calling cURL command from C++ returns unexpected error codes like 1792 and 6656
body: <p>I have a C++ application running on an embedded Linux that builds and calls cURL commands to copy files to an FTP server.</p>
  
  <pre><code>std::string cmd = "curl --connect-timeout 10 --ftp-create-dirs "
                    + localPath + filename + " "
                    + ftpPath + filename + " "
                    + userAuth;
  
  int retVal = system(cmd.c_str());
  </code></pre>
  
  <p>Depending on the variables to build the command, this returns unexpected error codes. For example, when I try to copy a file that doesn't exist, <code>retVal</code> is 6656 instead of the expected 26 ("local file not found"), and when I turn off the server, <code>retVal</code> is 1792 instead of the expected 7 ("could not connect to server").</p>
  
  <p>Looking at the values, I am pretty sure that this has something to do with endianness, but I would like to understand the root cause. The device has an ARMv7 processor and uses little endian format.</p>