我有这样的指针 => 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/