Привязать событие к родительскому объекту, который уже существует:
$(document).on("click", "selector", function() {
// Your code here
});
Не забывайте std::scanf
:
#include <cstdio>
std::size_t s;
if (std::scanf("Array has size: %zu", &s)) {
// ...
}
else {
throw MyException("Wrong format");
}