[Solved] Is there a Visual c++ compiler online and how convert between c++ and vs simple code


What does assert(false); does?

It opens an assert window. It’s a mechanism to let the programmer know when a control path that wasn’t supposed to be reached, is, or a condition that wasn’t supposed to fail, does.

Basically like:

int divide10ByX(int x)
{
   if ( x == 0 )
   {
      assert(!"x can't be 0");
      return 0;
   }
   return 10/x;
}

When x is 0, the program would normally crash. By checking beforehand, you prevent the crash, but can hide some wrong functionality because x isn’t supposed to be 0. So you put an assert there to inform you whenever x is 0.

Alternitively, it could be assert(x), which only triggers if x==0.

2

solved Is there a Visual c++ compiler online and how convert between c++ and vs simple code