why, is this weird behaviour of c++?

Revision en2, by rashid_aziz, 2022-08-02 19:45:38

include

using namespace std; int main() { string s = "abcd"; int i = -1; while(i < s.size()){ cout << "inside "; i++; } cout << "outside"; return 0; }

why this loop does not run, where as when we initialize i = 0, then it runs properly

Tags c++, string

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English rashid_aziz 2022-08-02 19:45:38 2 Tiny change: '#include <' -> '\n#include <'
en1 English rashid_aziz 2022-08-02 19:45:07 338 Initial revision (published)