C
1/* C */
2const char* text[] = { "Apple", "Orange", "Red" };
[追記]
C++
1// C++ : お好きなものをどうぞ
2std::string text[] = { "Apple", "Orange", "Red" };
3std::array<std::string,3> text = { "Apple", "Orange", "Red" };
4std::vector<std::string> text = { "Apple", "Orange", "Red" };
[追記]
C++
1#include <array>
2#include <vector>
3#include <string>
4#include <iostream>
5
6int main() {
7 std::array<std::string,3> text1 = { "Apple", "Orange", "Red" };
8 std::vector<std::string> text2 = { "Apple", "Orange", "Red" };
9 std::string text3[] = { "Apple", "Orange", "Red" };
10
11 for ( const auto& item : text1 ) std::cout << item << ' '; std::cout << std::endl;
12 for ( const auto& item : text2 ) std::cout << item << ' '; std::cout << std::endl;
13 for ( const auto& item : text3 ) std::cout << item << ' '; std::cout << std::endl;
14}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/09/12 12:18
2019/09/12 12:24 編集
2019/09/12 12:24
2019/09/12 12:26
2019/09/12 12:31