It will look something like this (full program).
#include <map>
#include <cstdlib>
int main() {
std::map<int, int> array;
for (int i = 1; i <= 10; ++i) {
array[i] = i;
}
return EXIT_SUCCESS;
}
I use the map above, since the PHP βarraysβ are actually similar to maps in other languages ββ(although completely mimicking their behavior in a statically typed language is a problem). Of course, since the program does little, you can save yourself spelling and not type in something that does nothing effectively.
EDIT:
#include <map>
#include <string>
#include <sstream>
#include <cstdlib>
int main() {
std::map<int, std::string> array;
for (int i = 1; i <= 10; ++i) {
std::ostringstream stream;
stream << "test" << i;
array[i] = stream.str();
}
return EXIT_SUCCESS;
}
source
share