+ 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;
5 odpowiedzi
0
Do not forget google!
https://www.geeksforgeeks.org/char-vs-stdstring-vs-char-c/
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
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