suppose..
Expand|Select|Wrap|Line Numbers
- string sum_string ="";
- getline(cin,sum_string);
- char *array =new char[sum_string.length()+1];
- sum_string.copy(array, sum_string.length()];
- cout<<sum_string.length()<<endl;
- cout<<strlen(array)<<endl;
- ....
- delele [] array;
- array =NULL;
ok fine sum_string.length() shows 8
BUT
strlen(array) is showing 12 ???
but that nothing strange yet...
for strings with greater length particularly those containing spaces both the output is same surprisingly......
again if i manually allocate 40 spaces i.e., char *array =new char[40];
then its doing fine with "mynameis"....
please help ASAP....