谁能告诉我这条程序有什么问题啊?
#include<iostream>#include<fstream>
#include<cmath>
using namespace std;
void WriteFile(char* str)
{
ofstream out1;
out1.open("out.txt",ios_base::binary|ios_base::app);
for(int i=0;str[i]!=0;i++)
out1.put(str[i]);
out1.close();
}
void fun(char* str)
{
for(int i=0;str!=0;i++)
if(str[i]>='a'&&str[i]<='z')
str[i]=str[i]+32;
if(str[i]>='A'&&str[i]<='Z')
str[i]=str[i]-32;
cout<<str[i]<<endl;
WriteFile(str);
}
void ClearFile()
{
ofstream out1;
out1.open("out.txt");
out1.close();
}
int main()
{
ClearFile();
char str[1024];
cout<<"please input a string: "<<endl;
cin.getline(str,1024);
fun(str);
return 0;
}
[ 本帖最后由 黄锋 于 2013-3-7 10:59 编辑 ]