+ 3

Can you hold strings inside an array??

is there any possible way to hold strings inside an array.

7th Feb 2017, 5:30 PM
Mr. Robot
Mr. Robot - avatar
10 Answers
+ 6
Yes you can: string s[10]; or string s[] = {"hi", "there"};
7th Feb 2017, 5:47 PM
Álvaro
+ 3
vector = array
16th Apr 2017, 4:40 PM
XOPGAMINGX _300
XOPGAMINGX _300 - avatar
+ 2
@teja, OК vector <string> strings; //←★initialize the vector for(string temp;cin>>temp;) strings.push_back(temp); //←★while read string add it to the end of the vector // ←★this loop will stop when it encounters an end of file copy(strings.begin(), strings.end(), ostream_iterator<string>(cout, "\n")); //←★it's function of simple output of the vector Anything else?
12th Feb 2017, 6:25 AM
SUPER_S
SUPER_S - avatar
+ 2
@teja Vector is a wrapper for the standard array in C++. It automatically increases its size if it overflows. The vector also contains many "Goodies" as fast sorting (#include <algorithm>, std:sort) simple output. It is appropriate and proper use could make the program faster and more functional.
12th Feb 2017, 7:07 AM
SUPER_S
SUPER_S - avatar
+ 1
String is even in the vectors can contain =) vector <string> strings; for(string temp;cin>>temp;) strings.push_back(temp); copy(strings.begin(), strings.end(), ostream_iterator<string>(std::cout, "\n"));
8th Feb 2017, 1:50 PM
SUPER_S
SUPER_S - avatar
+ 1
yes
8th Feb 2017, 6:27 PM
XOPGAMINGX _300
XOPGAMINGX _300 - avatar
+ 1
yes, in real it is very practical approach;)
26th Feb 2017, 8:15 PM
Highman
Highman - avatar
0
Mr. super_s can u explain ur example in detail please
12th Feb 2017, 6:10 AM
teja
teja - avatar
0
thank you Mr. super_s
12th Feb 2017, 6:29 AM
teja
teja - avatar
- 1
but what does a vector means
12th Feb 2017, 6:29 AM
teja
teja - avatar