#include
#include
void DeleteLower( char acstr[], int iCount )
{
int iTemp = 0;
char acTemp[30] = {0};
printf("您输入的字符串:%s\n",acstr);
for ( int i = 0; i < iCount; ++i )
{
if ( !(islower(acstr[i])) )
{
acTemp[iTemp] = acstr[i];
iTemp++;
}
}
printf("删除后的字符串:%s\n",acTemp);
}
void main()
{
printf("请输入字符串(小于30)\n");
char acstr[30] = {0};
scanf("%s",acstr);
DeleteLower(acstr,30);
}
这是用C++写的
void work(char str[])
{
int len=strlen(str),i,j;
char *ans=new char[len+1];
for(i=0,j=0;i
if( islower( str[i] ) )
ans[j++]=str[i];
}
for(i=0;i
str[i]='\0';
delete ans;
}