同为指针,后面一个为啥不对
#include <conio.h>#include <stdio.h>
#include <stdlib.h>
void fun(char *tt,int pp[] )
{int k;
for(k=0;k<26;k++)
pp[k]=0;
for(;*tt!='\0';tt++)
if(*tt>='a'&&*tt<='z')
pp[*tt-'a']+=1;
pp[k]='\0';
}
void main( )
{
FILE *wf;
char aa[1000];
int bb[26], k;
system("CLS");
printf("\nPlease enter a char string : ") ;
scanf("%s",aa);
fun(aa,bb);
for (k=0 ;k<26 ; k++)
printf("%d ",bb[k]) ;
printf("\n ");
/******************************/
wf=fopen("out.dat","w");
fun ("abcdefgabcdeabc",bb) ;
for (k=0 ;k<26 ; k++)
fprintf(wf,"%d ",bb[k]) ;
fclose(wf); getch();
/*****************************/
}后面一个为什么不对。请高人指点
#include <stdio.h>
#include <string.h>
void fun(char *s,char t[])
{
int n=0;
for(;*s!='\0';s++;)
{if(s%2==0 && *s%2==0)
t[n++]=*s;}
t[n]= '\0';
}
main()
{
FILE *out;
char s[100],t[100];
printf("\nPlease enter string S:");
scanf("%s", s);
fun(s,t);
printf("\nThe result is: %s\n",t);
out=fopen("out.dat","w");
fputs(t,out);
fclose(out);
}