online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <iostream> #include<string.h> using namespace std; int main() { //given input as "kjlp" I expect strlen(a) to be 4 //but this outputs 6 char a[80]; //char a[100]; //then changing to "char a[100]", or a[6] it outputs strlen(a) as 4 //why so?? a[0]=cin.get(); int i=0; while(a[i]!='p'){ cout<<a[i]; i++; a[i]=cin.get(); } cout<<strlen(a); return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue