Q:

setxkbmap returns 65280 when executed from system call

I am sending     
std::string cmdStr = "setxkbmap us";
int res = system( cmdStr.c_str() );

and the result is 
res: 65280

What can be the problem? 

A:

That value indicates that the child process exited normally with a value of 255. 
This could happen if:

/bin/sh couldn't find setxkbmap. ( note: I might be wrong on this one.  On my PC, /bin/sh returns 127 in that case.) 
setxkbmap couldn't open the X server at $DISPLAY, including if DISPLAY is unset

I'm sure that there are many other possibilities.  Check stdout for error messages. 
When interpreting the return value from system on Linux, do this:
#include <sys/wait.h>

int res = system(foo);
if(WIFEXITED(res)) {
  std::cout << "Normal exit: " << WEXITSTATUS(res) << "\n";
} else {
  if(WIFSIGNALED(res)) {
    std::cout << "Killed by signal #" << WTERMSIG(status);
    if(WCOREDUMP(res)) {
      std::cout << " Core dumped";
    }
    std::cout << "\n";
  } else {
    std::cout << "Unknown failure\n";
  }
}

