Code: Select all
std::string* myStrings = new std::string[4] { "Apples", "Oranges", "Bananas", "Coconuts" };
Moderator: Coders of Rage
Code: Select all
std::string* myStrings = new std::string[4] { "Apples", "Oranges", "Bananas", "Coconuts" };
Code: Select all
Jeremiah@mercury:~/Desktop% cat myStrings.cpp
#include <iostream>
#include <string>
int main()
{
std::string* myStrings = new std::string[4] { "Apples", "Oranges", "Bananas", "Coconuts" };
for (int i = 0; i < 4; ++i)
std::cout << i << ": " << myStrings[i] << std::endl;
return 0;
}
Jeremiah@mercury:~/Desktop% c++ myStrings.cpp -o myStrings
myStrings.cpp:5:48: error: expected ';' at end of declaration
std::string* myStrings = new std::string[4] { "Apples", "Oranges", "Bananas", "Coconuts" };
^
;
1 error generated.
Jeremiah@mercury:~/Desktop% c++ -std=c++11 -stdlib=libc++ myStrings.cpp -o myStrings
Jeremiah@mercury:~/Desktop% ./myStrings
0: Apples
1: Oranges
2: Bananas
3: Coconuts
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!