string* greetingArray()
{
string greetings[50000];
for(int i = 0; i < 50000; i++)
{
greetings[i++] = "Hi";
greetings[i++] = "Hey";
greetings[i++] = "Hello";
greetings[i++] = "What's up";
}
for (int i = 0; i < 50000; i++)
{
cout << greetings[i] << endl;
}
return 0;
}
int main()
{
greetingArray();
return 0;
}
for(int i = 0; i < 50000; i++)
{
greetings[i++] = "Hi";
greetings[i++] = "Hey";
greetings[i++] = "Hello";
greetings[i++] = "What's up";
}
for(int i = 0; i < 50000; i++)
{
greetings[i++] = "Hi";
greetings[i++] = "Hey";
greetings[i++] = "Hello";
greetings[i] = "What's up";
}
#define AMOUNT 50000 //change this number for whatever count of strings you need
std::vector<std::string> greetings;
while(greetings.size() < AMOUNT){
greetings.push_back("Hi");
greetings.push_back("Hey");
greetings.push_back("Hello");
greetings.push_back("What's up");
}
//print the vector's contents
for (std::vector<string>::iterator strIter = greetings.begin(); strIter != greetings.end(); ++strIter){
cout << *strIter << endl;
}
string*
string greetings[50000];
for(int i = 0; i < 50000; i++)
{
greetings[i++] = "Hi";
greetings[i++] = "Hey";
greetings[i++] = "Hello";
greetings[i++] = "What's up";
}
#include <iostream>
#include <string>
std::string * greetingArray( size_t n )
{
const size_t N = 4;
const char *words[N] = { "Hi", "Hey", "Hello", "What's up" };
std::string *greetings = new std::string[n];
for ( size_t i = 0; i < n; i++ )
{
greetings[i] = words[i % N];
}
return greetings;
}
int main()
{
size_t N = 50000;
std::string *greetings = greetingArray( N );
for ( size_t i = 0; i < N; i++ )
{
std::cout << greetings[i] << std::endl;
}
delete [] greetings;
return 0;
}
string* yourFunctionName();
{
string myArray[50000];
for(unsigned int i=0;i<12500;){
myArray[i*4]="Hi";
myArray[i*4+1]="Hey";
myArray[i*4+2]="Hello";
myArray[i*4+3]=What's up";
}
return myArray;
#include <iostream>
#include <array>
const unsigned arraySize = 50000;
std::array<std::string, arraySize> greetingArray()
{
std::array<std::string, arraySize> greetings;
for(unsigned i = 0; i != greetings.size(); i += 4)
{
greetings[i] = "Hi";
greetings[i+1] = "Hey";
greetings[i+2] = "Hello";
greetings[i+3] = "What's up";
}
return greetings; // return the array, not 0 !
}
int main()
{
std::array<std::string, arraySize> greetings = greetingArray();
for(unsigned i = 0; i != 20; ++i) std::cout << greetings.at(i) << 'n'; // 20 outputs is plenty to check if it worked
return 0;
}
{
string greetings[50000];
for(int i = 0; i < 50000; i++)
{
greetings[i++] = "Hi";
greetings[i++] = "Hey";
greetings[i++] = "Hello";
greetings[i++] = "What's up";
}
for (int i = 0; i < 50000; i++)
{
cout << greetings[i] << endl;
}
return 0;
}
int main()
{
greetingArray();
return 0;
}
for(int i = 0; i < 50000; i++)
{
greetings[i++] = "Hi";
greetings[i++] = "Hey";
greetings[i++] = "Hello";
greetings[i++] = "What's up";
}
for(int i = 0; i < 50000; i++)
{
greetings[i++] = "Hi";
greetings[i++] = "Hey";
greetings[i++] = "Hello";
greetings[i] = "What's up";
}
#define AMOUNT 50000 //change this number for whatever count of strings you need
std::vector<std::string> greetings;
while(greetings.size() < AMOUNT){
greetings.push_back("Hi");
greetings.push_back("Hey");
greetings.push_back("Hello");
greetings.push_back("What's up");
}
//print the vector's contents
for (std::vector<string>::iterator strIter = greetings.begin(); strIter != greetings.end(); ++strIter){
cout << *strIter << endl;
}
string*
string greetings[50000];
for(int i = 0; i < 50000; i++)
{
greetings[i++] = "Hi";
greetings[i++] = "Hey";
greetings[i++] = "Hello";
greetings[i++] = "What's up";
}
#include <iostream>
#include <string>
std::string * greetingArray( size_t n )
{
const size_t N = 4;
const char *words[N] = { "Hi", "Hey", "Hello", "What's up" };
std::string *greetings = new std::string[n];
for ( size_t i = 0; i < n; i++ )
{
greetings[i] = words[i % N];
}
return greetings;
}
int main()
{
size_t N = 50000;
std::string *greetings = greetingArray( N );
for ( size_t i = 0; i < N; i++ )
{
std::cout << greetings[i] << std::endl;
}
delete [] greetings;
return 0;
}
string* yourFunctionName();
{
string myArray[50000];
for(unsigned int i=0;i<12500;){
myArray[i*4]="Hi";
myArray[i*4+1]="Hey";
myArray[i*4+2]="Hello";
myArray[i*4+3]=What's up";
}
return myArray;
#include <iostream>
#include <array>
const unsigned arraySize = 50000;
std::array<std::string, arraySize> greetingArray()
{
std::array<std::string, arraySize> greetings;
for(unsigned i = 0; i != greetings.size(); i += 4)
{
greetings[i] = "Hi";
greetings[i+1] = "Hey";
greetings[i+2] = "Hello";
greetings[i+3] = "What's up";
}
return greetings; // return the array, not 0 !
}
int main()
{
std::array<std::string, arraySize> greetings = greetingArray();
for(unsigned i = 0; i != 20; ++i) std::cout << greetings.at(i) << 'n'; // 20 outputs is plenty to check if it worked
return 0;
}