Ask coding questions

← Back to all posts
Link code doesn't work properly!
Divy07 (0)

Code works just fine in the compiler but when i copy the URL and run it in other window, "attempts count" doesn't show up. Please help this is my first project with C++.

Answered by SPQR (432) [earned 5 cycles]
View Answer
Commentshotnewtop
SPQR (432)

I think the problem is that the repl exits before the program has time to output the number of attempts. Putting a for loop that counts up to 100000 or so might help, or you could #include <unistd.h> and usleep(10000) to add enough of a pause in the end of the program to give it time to work.
EDIT: if neither of those do it for you, try using larger numbers for the delay :)

This is as far as I know a repl.it only issue, so don't be discouraged from c++ by thinking it will do this on any machine. :)

ash15khng (471)

I see it on the repl.run?