【求助】为什么每次我把一个程序用两个文件分开写的时候都会这样?
这是主函数:程序代码:
#include<stdio.h> #include"f.cpp" int main() { int i; char str[10]; printf("请输入密码:\n"); gets(str); i=f(str,"password!"); if(i) printf("\n恭喜,密码正确!"); else printf("\n抱歉,密码错误!"); }
****************************下面是f.cpp文件内容********************
程序代码:
int f(char str[],char pw[]) { int i; while(str[i]==pw[i] && str[i]!='\0' && pw[i]!='\0') i++; return !(str[i]-pw[i])
***************************下面是错误提示************************
--------------------Configuration: main - Win32 Debug--------------------
Compiling...
main.cpp
c:\documents and settings\administrator\桌面\cpp\main.cpp(3) : error C2143: syntax error : missing ';' before 'PCH creation point'
c:\documents and settings\administrator\桌面\cpp\main.cpp(4) : error C2143: syntax error : missing ';' before '{'
c:\documents and settings\administrator\桌面\cpp\main.cpp(5) : error C2143: syntax error : missing ';' before 'PCH creation point'
c:\documents and settings\administrator\桌面\cpp\main.cpp(6) : error C2143: syntax error : missing ';' before 'PCH creation point'
c:\documents and settings\administrator\桌面\cpp\main.cpp(7) : error C2143: syntax error : missing ';' before 'PCH creation point'
c:\documents and settings\administrator\桌面\cpp\main.cpp(8) : error C2143: syntax error : missing ';' before 'PCH creation point'
c:\documents and settings\administrator\桌面\cpp\main.cpp(9) : error C2143: syntax error : missing ';' before 'PCH creation point'
c:\documents and settings\administrator\桌面\cpp\main.cpp(10) : error C2143: syntax error : missing ';' before 'PCH creation point'
c:\documents and settings\administrator\桌面\cpp\main.cpp(11) : error C2143: syntax error : missing ';' before 'PCH creation point'
c:\documents and settings\administrator\桌面\cpp\main.cpp(12) : error C2143: syntax error : missing ';' before 'PCH creation point'
c:\documents and settings\administrator\桌面\cpp\main.cpp(13) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
main.obj - 11 error(s), 0 warning(s)
求各位同学帮帮忙!谢谢