如何从数组 c++ 中的字符串打印第 N 个字符

How do you print an Nth character from a string in an array c++

本文关键字:打印 字符 字符串 数组 c++      更新时间:2023-10-16

我对编码很陌生,我只是有一个简短的问题。如何从 c++ 数组中的字符串中找到第 n 个字符?所以例如 {"Hey you" "echo" "lake" "lend" "degree"}n=0等于"你好"谢谢!我不打算要求提供完整的代码,而只是关于从哪里开始的提示。

以下是一些示例:

unsigned int n = 3;
static const char hello[] = "hello";
cout << hello[n] << "n";
const std::string apple = "apple";
cout << apple[n] << "n";
static const char * many[] = {"These", "are", "many", "strings"};
cout << many[n][n] << "n";
cout << many[n] << "n";