c++ - Segmentation fault issue -
i trying make system()
command move mouse using xdotool.
the following test program:
int main() { int x = 10; int y = 50; char* str; sprintf(str, "xdotool mousemove %d, %d", x, y); system(str); }
i getting segmentation fault (core dumped) error. there way know of allow such command work? i've tried root way. i'm new c++ , appreciated.
the other answers correct however, can use better methods in c++ rather using sprintf
int main() { int x = 10; int y = 50; std::stringstream ss; ss << "xdotool mousemove " << x << " " << y; system(ss.str().c_str()); }
Comments
Post a Comment