| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1204 人关注过本帖
标题:【求助】为什么每次我把一个程序用两个文件分开写的时候都会这样?
只看楼主 加入收藏
thlgood
Rank: 5Rank: 5
等 级:职业侠客
帖 子:281
专家分:381
注 册:2010-9-24
结帖率:91.43%
收藏
已结贴  问题点数:10 回复次数:11 
【求助】为什么每次我把一个程序用两个文件分开写的时候都会这样?
这是主函数:
程序代码:
#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
flyue
Rank: 10Rank: 10Rank: 10
来 自:江南西道
等 级:贵宾
威 望:19
帖 子:3465
专家分:1563
注 册:2006-6-20
收藏
得分:0 
VC安装路径被你修改了,只有重装vc

天之道,损有余而补不足.人之道则不然,损不足以奉有余.孰能有余以奉天下,唯有道者.
2011-02-22 08:59
丞相杀手
Rank: 6Rank: 6
等 级:侠之大者
帖 子:203
专家分:462
注 册:2011-1-11
收藏
得分:0 
以下是引用thlgood在2011-2-22 08:39:59的发言:

***************************下面是错误提示************************
--------------------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()
求各位同学帮帮忙!谢谢

上面有N行的提示你缺少分号……

斗不过疯子,不参与争论。
2011-02-22 09:18
flyue
Rank: 10Rank: 10Rank: 10
来 自:江南西道
等 级:贵宾
威 望:19
帖 子:3465
专家分:1563
注 册:2006-6-20
收藏
得分:0 
include cpp...

天之道,损有余而补不足.人之道则不然,损不足以奉有余.孰能有余以奉天下,唯有道者.
2011-02-22 09:22
laoyang103
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:内蒙古包头
等 级:贵宾
威 望:19
帖 子:3082
专家分:11056
注 册:2010-5-22
收藏
得分:2 
呵呵   想用别的文件中的函数   
最好是用动态链接库导出它  然后去调用

                                         
===========深入<----------------->浅出============
2011-02-22 10:30
laoyang103
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:内蒙古包头
等 级:贵宾
威 望:19
帖 子:3082
专家分:11056
注 册:2010-5-22
收藏
得分:1 
或者吧它加入到标准名空间去

                                         
===========深入<----------------->浅出============
2011-02-22 10:31
flyue
Rank: 10Rank: 10Rank: 10
来 自:江南西道
等 级:贵宾
威 望:19
帖 子:3465
专家分:1563
注 册:2006-6-20
收藏
得分:2 
C语言可没有namespace。
只要连接了对应函数的obj lib,以及一个声明,就能调用。

天之道,损有余而补不足.人之道则不然,损不足以奉有余.孰能有余以奉天下,唯有道者.
2011-02-22 10:40
cacker
该用户已被删除
收藏
得分:5 
提示: 作者被禁止或删除 内容自动屏蔽
2011-02-22 11:13
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
a343637412
Rank: 7Rank: 7Rank: 7
来 自:そ ら
等 级:黑侠
帖 子:357
专家分:620
注 册:2010-9-26
收藏
得分:0 



            占位置,  来学习
2011-02-22 12:32
快速回复:【求助】为什么每次我把一个程序用两个文件分开写的时候都会这样?
数据加载中...
 
   



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

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