+ 1

String Vs Ch Array C++

When to use string and ch array? Is there any performance difference? Can I use string all the time? char arr[10]; getline(cin , arr); string arr; cin >> a;

12th Jun 2020, 3:05 PM
Saad Saleem
Saad Saleem - avatar
5 Respuestas
12th Jun 2020, 4:55 PM
Bilbo Baggins
Bilbo Baggins - avatar
0
char arr[10]; getline(cin , arr); string arr; cin >> a; Is there only syntax difference between these two? When to use string and when to use ch array
12th Jun 2020, 5:07 PM
Saad Saleem
Saad Saleem - avatar
0
So on stack overflow I found the difference between these two char arr[10]; getline(cin , arr); // it allows spaces to store and read full line string arr; cin >> arr// it stops storing when space comes Input : hello world Output : hello
12th Jun 2020, 6:58 PM
Saad Saleem
Saad Saleem - avatar