How and when the output of other characters, find fault?

Category: C/C++ -> C Author: yinglin920 Date: 2006-01-24 19:00:25
 
yinglin920
2006-01-24 19:00:25
/ / Put a string of vowels was copied into another string
# include <stdio.h>
void cz (char str_1 [], char str_2 [])
{
int i, j = 0;
for (i = 0; str_1 [i]! = '\ 0'; i + +)
{
if ((str_1 [i]> = 'a') && (str_1 [i] <= 'z'))
{
str_2 [j] = str_1 [i];
j + +;
}
}
puts (str_2);
return;
}
void main ()
{
char str_1 [80], str_2 [80];
printf ("Please enter a string \ n");
gets (str_1);
cz ( str_1, str_2);
return;
}
xiao198917
2006-01-24 19:09:28

#include<stdio.h>
void cz(char str_1[],char str_2[])
{
int i,j=0;
for(i=0;str_1[i]!='\0';i++)
{
if((str_1[i]>='a') && (str_1[i]<='z'))//
{
str_2[j]=str_1[i];
j++;
}
}
str_2[j]='\0';//
puts(str_2);
return ;
}
void main()
{
char str_1[80],str_2[80];
printf(" \n");
gets(str_1);
cz(str_1,str_2);
return ;
}
jiyuanyi1992
2006-01-24 19:21:16
This is God horse mean
uiv19581113
2006-01-24 19:29:26
Upstairs solution you do not add end of string will put the memory together with some other information stored in the output
a7989325
2006-01-24 19:34:04
judge vowel This is good not write letters so what?
f ((str_1 [i] = 'a') | | (str_1 [i] = 'i') | | (str_1 [i] = 'u') | | (str_1 [i] = 'o') | | (str_1 [i] = 'e'))
{
str_2 [j] = str_1 [i];
j + +;
}