C++自定义路径 文件打不开

#include
#include
#include
using namespace std;
int main()
{
char a[80],path[40];
cout << "请输入文件保存的路径以#结束:" << endl;
cin.getline(path, 40, '#');
ofstream outfile(path, ios::binary);
if (!outfile){ cerr << "打开文件失败!" << endl; abort(); }
cin.getline(a, 80, '#');
for (int i = 0; a[i] != 0; i++)
{
if (a[i] >= 65 && a[i] <= 90 || a[i] >= 97 && a[i] <= 122)
{
if (a[i] >= 65 && a[i] <= 90)
{
if (a[i] >= 87){ a[i] -= 25; }
else
a[i] += 4;
}
if (a[i] >= 97 && a[i] <= 122)
{
if (a[i] >= 119){ a[i] -= 25; }
else a[i] += 4;
}//字母加密
}
outfile.write(&a[i], sizeof(a[i]));//加密之后写入磁盘
}
outfile.close();//关闭文件
ifstream infile(path, ios::binary);//打开输入文件
if (!infile){ cout << "打开文件失败!" << endl; abort( ); }
for (int i = 0; a[i] != 0; i++)
{
infile.read(&a[i], sizeof(a[i]));
if (a[i] >= 65 && a[i] <= 90 || a[i] >= 97 && a[i] <= 122)
{
if (a[i] >= 65 && a[i] <= 90)
{
if (a[i] >= 87){ a[i] += 25; }
else
a[i] -= 4;
}
if (a[i] >= 97 && a[i] <= 122)
{
if (a[i] >= 119){ a[i] += 25; }
else a[i] -= 4;
}//解密文件
}
cout << a[i];//输入解密后的文件
}
cout << endl;
return 0;
}
执行之后出现什么r6010的错误图片说明

查看全部
qq_29120007
qq_29120007
2015/06/24 13:39
  • c++
  • 自定义
  • 点赞
  • 收藏
  • 回答
    私信

3个回复