急!看不懂程序错在哪
C:\WEXAM\35010001\prog.c(17) : error C2065: 'P' : undeclared identifier
Error executing cl.exe.
——————————————————————————————————
prog.obj - 1 error(s), 0 warning(s)
#include <stdio.h>
#include <string.h>
#include <conio.h>
char xx[50][80];
int maxline = 0; /* 文章的总行数 */
int ReadDat(void);
void WriteDat(void);
void ConvertCharD(void)
{
char *p;
int i;
for (i=0;i<maxline;i++)
{p=xx[i];
while (*p)
{if(*p=='a') *p='z';
else if(*p>'a' && *p<='z') *p=*p+1;
P++;
}
}
}
void main()
{
if (ReadDat())
{
printf("数据文件IN.DAT不能打开!\n\007");
return;
}
ConvertCharD();
WriteDat();
}
int ReadDat(void)
{
FILE *fp;
int i = 0;
char *p;
if ((fp = fopen("IN.DAT", "r")) == NULL)
return 1;
while (fgets(xx[i], 80, fp) != NULL)
{
p = strchr(xx[i], '\n');
if (p)
*p = 0;
i++;
}
maxline = i;
fclose(fp);
return 0;
}
void WriteDat(void)
{
FILE *fp;
int i;
fp = fopen("OUT.DAT", "w");
for (i=0; i<maxline; i++)
{
printf("%s\n", xx[i]);
fprintf(fp, "%s\n", xx[i]);
}
fclose(fp);
}
P++;
应该是
p++;
注意区分大小写!
p改成小写