Difference between strings and arrays?

Hello every one! Can anyone tell me the diff between strings and arrays?
Here is sample:
------------------------------------------------------------------------
By String:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
#include <string>
using namespace std;

int main () {
  string mystr;
  cout << "What's your name? ";
  getline (cin, mystr);
  cout << "Hello " << mystr << ".\n";
  cout << "What is your favorite team? ";
  getline (cin, mystr);
  cout << "I like " << mystr << " too!\n";
  return 0;
}

----------------------------------------------------------------------------
By arrays:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
using namespace std;

int main () {
  char name[256], title[256];

  cout << "Enter your name: ";
  cin.getline (name,256);

  cout << "Enter your favourite movie: ";
  cin.getline (title,256);

  cout << name << "'s favourite movie is " << title;

  return 0;
}

----------------------------------------------------------------------
which is preferable and can i pick characters one by one in string?
Strings are preferable, because.

1) You don't have to manage the size yourself.
2) They can be resized.
3) They can be used elegantly with algorithms (with begin() and end() iterators).

can i pick characters one by one in string?

Yes. The same way as you'd do in an array:
http://cplusplus.com/reference/string/string/operator%5B%5D/

You can also use at() if you'd like an out-of-range exception to be thrown, when it's the case.
http://cplusplus.com/reference/string/string/at/
thanks bro and sorry for late reply!
Topic archived. No new replies allowed.