0
Creating char array using new operator!!!
Cin>>*p; Takes only one character even though i have mentioned char *p=new char[20] Why??? Hasn't the OS allocated 20 bytes for p now so why my program crashes when i enter a multiword character even if i have declared the array for it?
3 ответов
+ 1
There is a little difference between p* and a[20]. In the last case type contains size of array. cout (not a cin) is able to output arrays (usually string constants like "value"), but not a clear pointer.
Use std::string to handle strings.
+ 1
Additionally, to get input you use cin >> <variable>; instead of cin << <variable>; I'll take it as a typo, but a good point to remember, still.
+ 1
Yes ipang i messed a little