加密程序问题
我编写了一个加密程序,部分代码如下:
// 1.cpp : Defines the entry point for the application.
//
#include "stdafx.h "
#include "stdio.h "
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
if(!strlen(lpCmdLine)){
MessageBox(NULL, "没有文件参数,程序无法执行! ", "参数错误 ",MB_ICONERROR);
return 1;
}
FILE *fp1,*fp2;
fp1=fopen(lpCmdLine, "rb ");
if(fp1==NULL){
MessageBox(NULL, "文件无法打开,请确定文件是否存在! ", "文件错误 ",MB_ICONERROR);
return 1;
}
char stmpname[MAX_PATH];
strcpy(stmpname,lpCmdLine);
strcat(stmpname, ".tmp ");
fp2=fopen(stmpname, "wb ");
if(fp2==NULL){
MessageBox(NULL, "临时文件无法打开,请确定文件是否存在! ", "文件错误 ",MB_ICONERROR);
return 1;
}
char c=fgetc(fp1);
char ch=0
while(!feof(fp1)){
ch=c^624;
fputc(ch,fp2);
c=fgetc(fp1);
}
fclose(fp1);
fclose(fp2);
if(!DeleteFile(lpCmdLine)){
DeleteFile(stmpname);
MessageBox(NULL, "文件无法替换除,请确定文件是被占用! ", "文件错误 ",MB_ICONERROR);
return 1;
}
MoveFile(stmpname,lpCmdLine);
MessageBox(NULL, "加密完成! ", "成功 ",MB_ICONINFORMATION);
return 0;
}
但执行总提示:
--------------------Configuration: 1 - Win32 Debug--------------------
Compiling...
1.cpp
C:\Documents and Settings\a\桌面\VC\1\1.cpp(34) : error C2143: syntax error : missing '; ' before 'while '
执行 cl.exe 时出错.
1.exe - 1 error(s), 0 warning(s)
请问怎么解决,我是新手,请各位多多指教。
[解决办法]
C:\Documents and Settings\a\桌面\VC\1\1.cpp(34) : error C2143: syntax error : missing '; ' before 'while '
执行 cl.exe 时出错.
--------------------------
说明是你的语法有问题啊,可能是你少了或者用错了;或者{,或者},什么的,不一定是编译器提示的那些原因,但是是语法错误这是肯定的
[解决办法]
char ch=0; 这里你少个 ; 号
while(!feof(fp1)){
。。。。