cib
cib copied to clipboard
RuntimeError: index out of bounds
On the website https://tbfleming.github.io/cib/, keeping the example string-sorting code as-is, click "Compile" -> "wasm size: 14001", click "Run" -> "RuntimeError: index out of bounds"
Browser I use: Chrome: Version 83.0.4103.116 (Official Build) (64-bit) Firefox: 78.0.1 (64-bit)
Further investigations: Changing cout to printf works. Other examples with cout fails, and without cout, succeeds.
It seems there are something wrong with cout.
This is such a cool project, and I would love for this to get fixed, because it has great pedagogical uses for teaching C++ and giving students immediate feedback in the browser, regardless of their runtime environment.
I should also note some strange behavior in the output console even with printf. Here's a simple code snippet I'm testing
#include <stdio.h>
int main() {
printf("Hello world\n");
for (int i = 0; i < 10; i++) {
printf("%i ", i);
}
}
The first time I run it, I see
Hello world
the second time I run it, I see
0 1 2 3 4 5 6 7 8 9 Hello world
@ctralie If you put a cout<<endl at the end of main(), then this problem wouldn't occur. I may have fixed this in my stdin PR, but I forget because that was a long time ago.
Ah yes nice that did it, thanks @arasouli91!