#include "stdafx.h"
#include <iostream>
using namespace System;
using namespace std;
int main(array<System::String ^> ^args)
{
char str[]="how a re you ?";
int i,j;
while(str[j]!='\0')
{
if(str[j]!=' ')
{
str[i++]=str[j++];
}
else
{
str[i++]=str[j++];
while(str[j]==' ')
{
j++;
}
}
}
str[i]='\0';
cout<<str<<endl;
return 0;
}
程序編寫過程中出現的問題:
char *pstr 與char str[]不同,利用pstr遍歷字符串就要用pstr++,不能用pstr[i];