i am trying to set my own size to string array. how cin
overwrite the size of string.
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
int size; cin>>size;
char str[size];
cout << "Enter a string: ";
cin>> str;
cout << "string size: " << strlen(str);
return 0;
}
output:
5
Enter a string: hellobaby
string size: 9