| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1204 人关注过本帖
标题:【求助】为什么每次我把一个程序用两个文件分开写的时候都会这样?
取消只看楼主 加入收藏
thlgood
Rank: 5Rank: 5
等 级:职业侠客
帖 子:281
专家分:381
注 册:2010-9-24
结帖率:91.43%
收藏
已结贴  问题点数:10 回复次数:1 
【求助】为什么每次我把一个程序用两个文件分开写的时候都会这样?
这是主函数:
程序代码:
#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)
求各位同学帮帮忙!谢谢
2011-02-22 08:39
thlgood
Rank: 5Rank: 5
等 级:职业侠客
帖 子:281
专家分:381
注 册:2010-9-24
收藏
得分:0 
以下是引用laoyang103在2011-2-22 10:30:32的发言:

呵呵   想用别的文件中的函数   
最好是用动态链接库导出它  然后去调用


********************************************************
额~这个真的不太懂!动态链接库?我上网找找看

o(∩∩)Linux & Python 群:187367181
2011-02-22 11:25
快速回复:【求助】为什么每次我把一个程序用两个文件分开写的时候都会这样?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011727 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved