0
Can we eliminate usage of char* in c++
Hi all Sorry for very basic question. As we always say that we should prefer string over char*, is it safe to say that don't ever use char* and just go with string.
3 Respostas
+ 2
In my opinion, yes.
The use of char * should be replaced with the use of std::string_view and std::string in C++ programs. I really don't see the advantage of using the plain old C-style strings
+ 2
It's not wise to say that don't use char* at all. Just that substituting char with string gives more flexibility as youve various add ons in string functions. So your code is pointer free (i mean to say that asterisk free and looks easy to read) and also pretty neat to understand. But where you deal with single char then go with char data type. But for names/address/simple words i generally prefer strings.
0
I am not denying on char. It's must to use char for single character but concern is where is use case of char* over string ?