关于array of pointer to char的疑问
K&R的书里第94页写了char * lineptr[MAXLINES];
void writelines(char * lineptr[],int nlines)
{
while (nlines-->0)
printf("%s\n",*lineptr++);
}
直接用数组名可以输出,可是我下面的语句为什么总是报错?
#define NL printf("\n")
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
char s1[]="gswa";
char s2[]="wym";
char s3[]="zyx";
char s4[]="kwl";
char * pp[4];
pp[0]=s1;
pp[1]=s2;
pp[2]=s3;
pp[3]=s4;
int i001;
for (i001=0;i001<4;i001++) cout<<pp[i001]<<'\t';
NL;
for (i001=0;i001<4;i001++) printf("%s\t",*pp++);//报错
NL;
return 0;
}
错误信息是iso c++ forbid cast to non-reference type used as lvalue.是编译器标准更严格了吗?