Can anyone spot the reason why nothing gets printed onto console using below C++ code;
string array[] = { "a", "b", "c", "d" };
int length = sizeof(array);
try
{
for (int i = 0; i < length; i++)
{
if (array[i] != "") cout << array[i];
}
}
catch (exception &e)
{
e.what();
}
You use the wrong length:
The actual reason you don’t see anything on the console is because the output is buffered, and since you haven’t wrote a newline it’s not flushed. In the meantime your app crashes.