c - 我想使用指针

标签 c pointers

我有这样的指针 => char* str={"you","we","they"};

我想用“我们”或“他们”。这怎么可能?

你能了解一下指针吗?

最佳答案

你的意思似乎是这样的

char *str[] = { "you", "we", "they" };

for ( size_t i = 0; i < sizeof( str ) / sizeof( *str ); i++ )
{
    puts( str[i] );
}

或者

char *str[] = { "you", "we", "they" };

for ( size_t i = 0; i < sizeof( str ) / sizeof( *str ); i++ )
{
    for ( char *p = str[i]; *p != '\0'; ++p ) putc( *p );
    printf( "\n" );
}

关于c - 我想使用指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28912984/

相关文章:

c++ - 函数原型(prototype)和数组参数

c - 在 C 中将 char 数组作为参数传递为指针

c - PETSc 示例不起作用

c++ - 优化范围检查和返回值

c++ - C、C++中的声明和排列代码的习惯

c - 一个 Void 指针的内存

c++ - 使用关系运算符比较指针是什么意思?

将字母排列与字典 C 进行比较

c++ - 指针 - 动态分配困惑

c++ - (char *) (msg +1) 这个 +1 带我们去哪里?