请大伙帮帮忙,看一下哪错了?
我刚学c语言,这两个程序我想了一上午也不知哪错了?1·
#include <stdio.h>
#define N 80
main()
{
char s[N];
char *p;
printf("\nPlease input a string:");
gets(s);
printf("Initital string :%s\n",s);
p=s;
while(*P)
{
if(*p>='a' && *p<='z') *p+='A'-'a';
else if(*p>='A' && *p<='Z') *p+='a'-'A';
p++;
}
printf("After covert:%s\n",s);
}
编译后:
C:\Users\dell\Desktop\1.c(11) : error C2065: 'P' : undeclared identifier
C:\Users\dell\Desktop\1.c(11) : error C2100: illegal indirection
执行 cl.exe 时出错.
1.obj - 1 error(s), 0 warning(s)
2·
#include"stdio.h"
#define N 10
main()
{
int a[N];
int *p;
int i,counter;
printf("\nPlease input %d integers:",N);
p=a;
for(i=0;i<N;i++)
scanf("%d",p+i);
counter=0;
for(i=0,i<N,i++)
{
if(p[i]%2==0)
counter++;
}
printf("There are %d Even numbers.\n",counter);
}
编译后
c:\users\dell\desktop\2.c(13) : error C2143: syntax error : missing ';' before ')'
c:\users\dell\desktop\2.c(13) : error C2143: syntax error : missing ';' before ')'
执行 cl.exe 时出错.
2.obj - 1 error(s), 0 warning(s)
不知为什么,怎么改也不对
[ 本帖最后由 天欲逍遥 于 2011-5-14 14:26 编辑 ]