请问我编的这个程序出了神马状况????

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
头像
mopperwhite
帖子: 330
注册时间: 2010-05-02 20:25
来自: 柯伊伯带外奥尔特云内轨道与黄道错开的空间站里

请问我编的这个程序出了神马状况????

#1

帖子 mopperwhite » 2011-01-08 14:15

RT
g++ -Wall -c "加密.cpp" (在目录/home/kzk/编程/C中)
加密.cpp: In function ‘void jia_mi(char*)’:
加密.cpp:49: error: invalid conversion from ‘char*’ to ‘char’
编译失败
加密.cpp: In function ‘void jie_mi(char*)’:
加密.cpp:62: error: invalid operands of types ‘char’ and ‘char*’ to binary ‘operator-’
加密.cpp:62: error: in evaluation of ‘operator-=(char, char*)’
加密.cpp: In function ‘void read()’:
加密.cpp:81: warning: format ‘%c’ expects type ‘char*’, but argument 2 has type ‘int’
加密.cpp:86: error: invalid conversion from ‘char’ to ‘char*’
加密.cpp:86: error: initializing argument 1 of ‘void jia_mi(char*)’
加密.cpp:92: error: invalid conversion from ‘char’ to ‘char*’
加密.cpp:92: error: initializing argument 1 of ‘void jie_mi(char*)’
MW加密_bate_0.01.tar.gz
这是源代码~~
(1.94 KiB) 已下载 34 次
求解!!!
:em20 :em20 :em20 :em20 :em20
愿他们残酷,但是永远正义
愿恐惧永远不会主宰他们的行动并愿民族的荣誉在他们心中高于一切
最后,愿他们最终可以理解,为完成我们建立民族社会主义国家的任务,需要数百年时间并需要每一个人永远将共同的利益置于个人利益之上。
----希特勒绝笔
讨厌我的人可以试着点一下
讨厌我的人可以试着点一下2.0bate
头像
cuihao
帖子: 4793
注册时间: 2008-07-24 11:33
来自: 郑州
联系:

Re: 请问我编的这个程序出了神马状况????

#2

帖子 cuihao » 2011-01-08 14:22

in.cpp: 在函数‘int jin(int)’中:
in.cpp:12:8: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:13:8: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:14:8: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:15:9: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:15:19: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:15:29: 错误:ISO C++ 不允许比较指针和整数的值
In file included from main.cpp:38:0:
in.cpp: 在函数‘int jin(int)’中:
in.cpp:12:8: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:13:8: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:14:8: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:15:9: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:15:19: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:15:29: 错误:ISO C++ 不允许比较指针和整数的值
In file included from unlock.cpp:6:0,
from main.cpp:40:
out.cpp: 在函数‘void out(char*)’中:
out.cpp:6:6: 错误:‘void out(char*)’ 重定义
out.cpp:6:6: 错误:‘void out(char*)’已在此定义过
/usr/include/stdio.h: 在函数‘int main()’中:
/usr/include/stdio.h:540:12: 错误:给予 function‘int getchar()’的参数太多
/usr/include/stdio.h:540:12: 附注:在此声明
/usr/include/stdio.h:540:12: 错误:给予 function‘int getchar()’的参数太多
/usr/include/stdio.h:540:12: 附注:在此声明

in.cpp:

代码: 全选

if(i=="l") return 1;
"i"是字符串,应该改成'i'. 其他错误自己看看。
求人不如求它仨: 天蓝的Wiki 屎黄的Wiki 绿
Site: CUIHAO.TK    Twitter: @cuihaoleo
Machine: Athlon64 X2 5200+ / 2x2GB DDR2-800 / GeForce GTS 450
AD: ~まだ見ぬ誰かの笑顔のために~
头像
cuihao
帖子: 4793
注册时间: 2008-07-24 11:33
来自: 郑州
联系:

Re: 请问我编的这个程序出了神马状况????

#3

帖子 cuihao » 2011-01-08 14:24

LZ应该写标准的程序。

你的程序完全就是C语言的,却要cpp扩展名。
求人不如求它仨: 天蓝的Wiki 屎黄的Wiki 绿
Site: CUIHAO.TK    Twitter: @cuihaoleo
Machine: Athlon64 X2 5200+ / 2x2GB DDR2-800 / GeForce GTS 450
AD: ~まだ見ぬ誰かの笑顔のために~
头像
mopperwhite
帖子: 330
注册时间: 2010-05-02 20:25
来自: 柯伊伯带外奥尔特云内轨道与黄道错开的空间站里

Re: 请问我编的这个程序出了神马状况????

#4

帖子 mopperwhite » 2011-01-08 14:24

main.cpp:

代码: 全选

//		MopperWhite的加密软件 bate 0.01
//      main.cpp
//      
//      Copyright 2011 MopperWhite <mopperwhite@mw-loptop>
//      
//      This program is free software; you can redistribute it and/or modify
//      it under the terms of the GNU General Public License as published by
//      the Free Software Foundation; either version 2 of the License, or
//      (at your option) any later version.
//      
//      This program is distributed in the hope that it will be useful,
//      but WITHOUT ANY WARRANTY; without even the implied warranty of
//      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//      GNU General Public License for more details.
//      
//      You should have received a copy of the GNU General Public License
//      along with this program; if not, write to the Free Software
//      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//      MA 02110-1301, USA.
//      This program is free software; you can redistribute it and/or modify
//      it under the terms of the GNU General Public License as published by
//      the Free Software Foundation; either version 2 of the License, or
//      (at your option) any later version.
//      
//      This program is distributed in the hope that it will be useful,
//      but WITHOUT ANY WARRANTY; without even the implied warranty of
//      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//      GNU General Public License for more details.
//      
//      You should have received a copy of the GNU General Public License
//      along with this program; if not, write to the Free Software
//      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//      MA 02110-1301, USA.


#include<stdio.h>
#include<string.h>
#include"in.cpp"
#include"lock.cpp"
#include"unlock.cpp"
#define MAXN 1000000
int main()
{
	char _b[10];
	char rin[MAXN];
	char passwd[MAXN];
	int jinn=jin(MAXN);
	if(jinn==1) sprintf(_b,"%s","加密");
	if(jinn==2) sprintf(_b,"%s","解密");
	if(jinn==3) return 0;
		else
		{
			printf("起始模块发生位置错误");
			return 0;
		}
	printf("请输入您要%s的内容,输完请按回车:\n",_b);
	getchar(rin);
	printf("请输入密码:");
	getchar(passwd);
	if(jinn==1) lock(rin,passwd);
	if(jinn==2) unlock(rin,passwd);
	return 0;
}
//软件生来自由!!!!!!!!

in.cpp:

代码: 全选

//By MopperWhite
//Copyright@MopperWhite
//C++ File
#include<stdio.h>
int jin(int max)
{
	char i;
	printf("*************************************************\n本软件使用GPL协议发布,您可以随意更改、复制、使用它的源代码\n*************************************************\n\n");
	printf("本软件暂时不能识别换行(俗称回车),请一段一段进行\n本软件能读取的内容长度仅限于%d个字节(%d个汉字)'\n由于算法不同,本软件能解密同一软件加密的数据,当然,您可以自己修改它的源码来更改算法 XD\n",max,max/2);
	printf("请问您想加密文件还是解密文件?\n若加密请输“l”,解密请输“u”,退出请输入“e”\nYou:");
	scanf("%c",&i);
	if(i=="l") return 1;
	if(i=="u") return 2;
	if(i=="e") return 3;
	if((i!="l")&&(i!="u")&&(i!="e"))
				{
					printf("请再看看上面的提示!!");
					return jin(max);
				}
	return 0;
}

lock.cpp:

代码: 全选

//By MopperWhite
//Copyright@MopperWhite
//C++ File
#include<stdio.h>
#include<string.h>
#include"out.cpp"
void lock(char rin[],char passwd[])
{
	int n=strlen(rin);
	int m=strlen(passwd);
	int i,j=0;
	for(i=0;i<n;i++,j++)
	{
		rin[i]=rin[i]+passwd[j]+31;
		if(j>=m-1) j=-1;
	}
	out(rin);
}

unlock.cpp:

代码: 全选

//By MopperWhite
//Copyright@MopperWhite
//C++ File
#include<stdio.h>
#include<string.h>
#include"out.cpp"
void unlock(char rin[],char passwd[])
{
	int n=strlen(rin);
	int m=strlen(passwd);
	int i,j=0;
	for(i=0;i<n;i++,j++)
	{
		rin[i]=rin[i]-passwd[j]-31;
		if(j>=m-1) j=-1;
	}
	out(rin);
}

out.cpp:

代码: 全选

//By MopperWhite
//Copyright@MopperWhite
//C++ File
#include<stdio.h>
#include<string.h>
void out(char rin[])
{
	printf("以下为处理结果:\n%s",rin);
	printf("\n\n========================我是分割线~=========================\n最后说一下,本软件是开源软件,理论上您应该可以从装它的压缩包里找到源代码\n友情提示:OGC伤身体(不要深究它的意思……)\n感谢您的使用~~~~~  XD");
}
愿他们残酷,但是永远正义
愿恐惧永远不会主宰他们的行动并愿民族的荣誉在他们心中高于一切
最后,愿他们最终可以理解,为完成我们建立民族社会主义国家的任务,需要数百年时间并需要每一个人永远将共同的利益置于个人利益之上。
----希特勒绝笔
讨厌我的人可以试着点一下
讨厌我的人可以试着点一下2.0bate
头像
mopperwhite
帖子: 330
注册时间: 2010-05-02 20:25
来自: 柯伊伯带外奥尔特云内轨道与黄道错开的空间站里

Re: 请问我编的这个程序出了神马状况????

#5

帖子 mopperwhite » 2011-01-08 14:26

cuihao 写了:in.cpp: 在函数‘int jin(int)’中:
in.cpp:12:8: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:13:8: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:14:8: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:15:9: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:15:19: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:15:29: 错误:ISO C++ 不允许比较指针和整数的值
In file included from main.cpp:38:0:
in.cpp: 在函数‘int jin(int)’中:
in.cpp:12:8: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:13:8: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:14:8: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:15:9: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:15:19: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:15:29: 错误:ISO C++ 不允许比较指针和整数的值
In file included from unlock.cpp:6:0,
from main.cpp:40:
out.cpp: 在函数‘void out(char*)’中:
out.cpp:6:6: 错误:‘void out(char*)’ 重定义
out.cpp:6:6: 错误:‘void out(char*)’已在此定义过
/usr/include/stdio.h: 在函数‘int main()’中:
/usr/include/stdio.h:540:12: 错误:给予 function‘int getchar()’的参数太多
/usr/include/stdio.h:540:12: 附注:在此声明
/usr/include/stdio.h:540:12: 错误:给予 function‘int getchar()’的参数太多
/usr/include/stdio.h:540:12: 附注:在此声明

in.cpp:

代码: 全选

if(i=="l") return 1;
"i"是字符串,应该改成'i'. 其他错误自己看看。
谢谢大家!!

把i改掉,成功了……………………
我的C白学了………………
愿他们残酷,但是永远正义
愿恐惧永远不会主宰他们的行动并愿民族的荣誉在他们心中高于一切
最后,愿他们最终可以理解,为完成我们建立民族社会主义国家的任务,需要数百年时间并需要每一个人永远将共同的利益置于个人利益之上。
----希特勒绝笔
讨厌我的人可以试着点一下
讨厌我的人可以试着点一下2.0bate
头像
mopperwhite
帖子: 330
注册时间: 2010-05-02 20:25
来自: 柯伊伯带外奥尔特云内轨道与黄道错开的空间站里

Re: 请问我编的这个程序出了神马状况????

#6

帖子 mopperwhite » 2011-01-08 14:27

cuihao 写了:LZ应该写标准的程序。

你的程序完全就是C语言的,却要cpp扩展名。
只有C++才能拆成几分
老师说我应该习惯存成cpp……
愿他们残酷,但是永远正义
愿恐惧永远不会主宰他们的行动并愿民族的荣誉在他们心中高于一切
最后,愿他们最终可以理解,为完成我们建立民族社会主义国家的任务,需要数百年时间并需要每一个人永远将共同的利益置于个人利益之上。
----希特勒绝笔
讨厌我的人可以试着点一下
讨厌我的人可以试着点一下2.0bate
头像
mopperwhite
帖子: 330
注册时间: 2010-05-02 20:25
来自: 柯伊伯带外奥尔特云内轨道与黄道错开的空间站里

Re: 请问我编的这个程序出了神马状况????

#7

帖子 mopperwhite » 2011-01-08 14:30

cuihao 写了:in.cpp: 在函数‘int jin(int)’中:
in.cpp:12:8: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:13:8: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:14:8: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:15:9: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:15:19: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:15:29: 错误:ISO C++ 不允许比较指针和整数的值
In file included from main.cpp:38:0:
in.cpp: 在函数‘int jin(int)’中:
in.cpp:12:8: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:13:8: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:14:8: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:15:9: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:15:19: 错误:ISO C++ 不允许比较指针和整数的值
in.cpp:15:29: 错误:ISO C++ 不允许比较指针和整数的值
In file included from unlock.cpp:6:0,
from main.cpp:40:
out.cpp: 在函数‘void out(char*)’中:
out.cpp:6:6: 错误:‘void out(char*)’ 重定义
out.cpp:6:6: 错误:‘void out(char*)’已在此定义过
/usr/include/stdio.h: 在函数‘int main()’中:
/usr/include/stdio.h:540:12: 错误:给予 function‘int getchar()’的参数太多
/usr/include/stdio.h:540:12: 附注:在此声明
/usr/include/stdio.h:540:12: 错误:给予 function‘int getchar()’的参数太多
/usr/include/stdio.h:540:12: 附注:在此声明

in.cpp:

代码: 全选

if(i=="l") return 1;
"i"是字符串,应该改成'i'. 其他错误自己看看。

getchar 和out到底是咋了??
愿他们残酷,但是永远正义
愿恐惧永远不会主宰他们的行动并愿民族的荣誉在他们心中高于一切
最后,愿他们最终可以理解,为完成我们建立民族社会主义国家的任务,需要数百年时间并需要每一个人永远将共同的利益置于个人利益之上。
----希特勒绝笔
讨厌我的人可以试着点一下
讨厌我的人可以试着点一下2.0bate
头像
cuihao
帖子: 4793
注册时间: 2008-07-24 11:33
来自: 郑州
联系:

Re: 请问我编的这个程序出了神马状况????

#8

帖子 cuihao » 2011-01-08 14:35

out那个是重复include造成的,每次include一个文件,预编译器都会复制一遍该文件。
建议把所有函数声明都放在一个头文件里,用ifdef防止重复include。
求人不如求它仨: 天蓝的Wiki 屎黄的Wiki 绿
Site: CUIHAO.TK    Twitter: @cuihaoleo
Machine: Athlon64 X2 5200+ / 2x2GB DDR2-800 / GeForce GTS 450
AD: ~まだ見ぬ誰かの笑顔のために~
头像
cuihao
帖子: 4793
注册时间: 2008-07-24 11:33
来自: 郑州
联系:

Re: 请问我编的这个程序出了神马状况????

#9

帖子 cuihao » 2011-01-08 14:36

mopperwhite 写了:
cuihao 写了:LZ应该写标准的程序。

你的程序完全就是C语言的,却要cpp扩展名。
只有C++才能拆成几分
老师说我应该习惯存成cpp……
:em06 你们老师没搞错把,谁说只有C++才能拆分?
看看GTK,全用C写的.
求人不如求它仨: 天蓝的Wiki 屎黄的Wiki 绿
Site: CUIHAO.TK    Twitter: @cuihaoleo
Machine: Athlon64 X2 5200+ / 2x2GB DDR2-800 / GeForce GTS 450
AD: ~まだ見ぬ誰かの笑顔のために~
头像
cuihao
帖子: 4793
注册时间: 2008-07-24 11:33
来自: 郑州
联系:

Re: 请问我编的这个程序出了神马状况????

#10

帖子 cuihao » 2011-01-08 14:44

getchar是这么用的:

代码: 全选

变量=getchar();
读一个字符,不是用来读取字符串的。
求人不如求它仨: 天蓝的Wiki 屎黄的Wiki 绿
Site: CUIHAO.TK    Twitter: @cuihaoleo
Machine: Athlon64 X2 5200+ / 2x2GB DDR2-800 / GeForce GTS 450
AD: ~まだ見ぬ誰かの笑顔のために~
头像
mopperwhite
帖子: 330
注册时间: 2010-05-02 20:25
来自: 柯伊伯带外奥尔特云内轨道与黄道错开的空间站里

Re: 请问我编的这个程序出了神马状况????

#11

帖子 mopperwhite » 2011-01-08 15:23

cuihao 写了:
mopperwhite 写了:
cuihao 写了:LZ应该写标准的程序。

你的程序完全就是C语言的,却要cpp扩展名。
只有C++才能拆成几分
老师说我应该习惯存成cpp……
:em06 你们老师没搞错把,谁说只有C++才能拆分?
看看GTK,全用C写的.
同学说的……………… :em20
老师让我们用cpp编C…… :em06
学习了……
求gtk教程………………
愿他们残酷,但是永远正义
愿恐惧永远不会主宰他们的行动并愿民族的荣誉在他们心中高于一切
最后,愿他们最终可以理解,为完成我们建立民族社会主义国家的任务,需要数百年时间并需要每一个人永远将共同的利益置于个人利益之上。
----希特勒绝笔
讨厌我的人可以试着点一下
讨厌我的人可以试着点一下2.0bate
头像
mopperwhite
帖子: 330
注册时间: 2010-05-02 20:25
来自: 柯伊伯带外奥尔特云内轨道与黄道错开的空间站里

Re: 请问我编的这个程序出了神马状况????

#12

帖子 mopperwhite » 2011-01-08 15:44

cuihao 写了:getchar是这么用的:

代码: 全选

变量=getchar();
读一个字符,不是用来读取字符串的。
想起来了!是gets()!!! :em01
愿他们残酷,但是永远正义
愿恐惧永远不会主宰他们的行动并愿民族的荣誉在他们心中高于一切
最后,愿他们最终可以理解,为完成我们建立民族社会主义国家的任务,需要数百年时间并需要每一个人永远将共同的利益置于个人利益之上。
----希特勒绝笔
讨厌我的人可以试着点一下
讨厌我的人可以试着点一下2.0bate
头像
upsuper
帖子: 361
注册时间: 2008-06-08 13:31
来自: 福州
联系:

Re: 请问我编的这个程序出了神马状况????

#13

帖子 upsuper » 2011-01-08 19:37

cuihao 写了:
mopperwhite 写了:
cuihao 写了:LZ应该写标准的程序。

你的程序完全就是C语言的,却要cpp扩展名。
只有C++才能拆成几分
老师说我应该习惯存成cpp……
:em06 你们老师没搞错把,谁说只有C++才能拆分?
看看GTK,全用C写的.
Linux Kernel 还是C和汇编写的……不能拆分的话实在难以想像那个文件的大小……
欢迎来我的小站:http://upsuper.org
头像
mopperwhite
帖子: 330
注册时间: 2010-05-02 20:25
来自: 柯伊伯带外奥尔特云内轨道与黄道错开的空间站里

Re: 请问我编的这个程序出了神马状况????

#14

帖子 mopperwhite » 2011-01-08 21:05

貌似现在只有out.cpp有问题
我把代码发上来
main.cpp

代码: 全选

//		MopperWhite的加密软件 bate 0.01
//      main.cpp
//      
//      Copyright 2011 MopperWhite <mopperwhite@mw-loptop>
//      
//      This program is free software; you can redistribute it and/or modify
//      it under the terms of the GNU General Public License as published by
//      the Free Software Foundation; either version 2 of the License, or
//      (at your option) any later version.
//      
//      This program is distributed in the hope that it will be useful,
//      but WITHOUT ANY WARRANTY; without even the implied warranty of
//      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//      GNU General Public License for more details.
//      
//      You should have received a copy of the GNU General Public License
//      along with this program; if not, write to the Free Software
//      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//      MA 02110-1301, USA.
//      This program is free software; you can redistribute it and/or modify
//      it under the terms of the GNU General Public License as published by
//      the Free Software Foundation; either version 2 of the License, or
//      (at your option) any later version.
//      
//      This program is distributed in the hope that it will be useful,
//      but WITHOUT ANY WARRANTY; without even the implied warranty of
//      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//      GNU General Public License for more details.
//      
//      You should have received a copy of the GNU General Public License
//      along with this program; if not, write to the Free Software
//      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//      MA 02110-1301, USA.


#include<stdio.h>
#include<string.h>
#include"in.cpp"
#include"lock.cpp"
#include"unlock.cpp"
#define MAXN 1000000
int main()
{
	char _b[10];
	char rin[MAXN];
	char passwd[MAXN];
	int jinn=jin(MAXN);
	if(jinn==1) sprintf(_b,"%s","加密");
	if(jinn==2) sprintf(_b,"%s","解密");
	if(jinn==3) return 0;
		else
		{
			printf("起始模块发生位置错误");
			return 0;
		}
	printf("请输入您要%s的内容,输完请按回车:\n",_b);
	gets(rin);
	printf("请输入密码:");
	gets(passwd);
	if(jinn==1) lock(rin,passwd);
	if(jinn==2) unlock(rin,passwd);
	return 0;
}
//软件生来自由!!!!!!!!
out.cpp:

代码: 全选

//By MopperWhite
//Copyright@MopperWhite
//C++ File
void out(char rin[])
{
	printf("以下为处理结果:\n%s",rin);
	printf("\n\n========================我是分割线~=========================\n最后说一下,本软件是开源软件,理论上您应该可以从装它的压缩包里找到源代码\n友情提示:OGC伤身体(不要深究它的意思……)\n感谢您的使用~~~~~  XD");
}

错误信息:
g++ -Wall -c "main.cpp" (在目录/home/kzk/桌面/加密bate0.01中)
In file included from unlock.cpp:6,
from main.cpp:40:
out.cpp: In function ‘void out(char*)’:
out.cpp:4: error: redefinition of ‘void out(char*)’
out.cpp:4: error: ‘void out(char*)’ previously defined here
编译失败
愿他们残酷,但是永远正义
愿恐惧永远不会主宰他们的行动并愿民族的荣誉在他们心中高于一切
最后,愿他们最终可以理解,为完成我们建立民族社会主义国家的任务,需要数百年时间并需要每一个人永远将共同的利益置于个人利益之上。
----希特勒绝笔
讨厌我的人可以试着点一下
讨厌我的人可以试着点一下2.0bate
头像
cuihao
帖子: 4793
注册时间: 2008-07-24 11:33
来自: 郑州
联系:

Re: 请问我编的这个程序出了神马状况????

#15

帖子 cuihao » 2011-01-08 22:23

同时include一个文件多次,如果不加IFNDEF之类的判断,必然会因为重复定义出错。

哎,LZ学习学习头文件吧。
说实话,include源代码我还是第一次见。
求人不如求它仨: 天蓝的Wiki 屎黄的Wiki 绿
Site: CUIHAO.TK    Twitter: @cuihaoleo
Machine: Athlon64 X2 5200+ / 2x2GB DDR2-800 / GeForce GTS 450
AD: ~まだ見ぬ誰かの笑顔のために~
回复