/tmp/ccjiJKv2.o:在函数sqrt中, collect2:ld返回1退出状态
func':
b.c:(.text+0x16b): undefined reference to
这是代码,我正在使用gcc编译器..
/*Write a function that receive 5 integers and returns the sum,average and standard deviation of these numbers*/
/*Author:Udit Gupta Date:10/08/2011*/
#include<stdio.h>
#include<math.h>
void func (int *,float *,float *);
int main () {
float avg,std_dev;
int sum;
func (&sum,&avg,&std_dev); /*Passing address of variables where output will be stored.....*/
printf ("The sum of numbers is %d\n",sum);
printf ("The average of numbers is %f\n",avg);
printf ("The standard deviation of numbers is %f\n",std_dev);
}
void func …Run Code Online (Sandbox Code Playgroud) 我试图编写一个函数来计算使用递归的数字的总和,但输出是不正确的.这是代码:
/*Write a function to calculate sum of digits of a number using recursion*/
/*Author:Udit Gupta Date:10/08/2011*/
#include<stdio.h>
int sum (int);
int main () {
int n,s;
printf ("Enter the number:");
scanf ("%d",&n);
s = sum (n);
printf ("The sum of the digits of the number is %d",s);
}
int sum (int a) {
int f;
if (a == 0) {
return f;
}
f = (a% 10) + sum (a/10);
}
Run Code Online (Sandbox Code Playgroud)
以下是一些输出值:
udit@udit-Dabba ~/Desktop/letusc/ch5/J $ ./a2.out
Enter the number:123 …Run Code Online (Sandbox Code Playgroud) 这个看起来像我以前的帖子的重复,但它不是.....
这里Valgrind发出以下错误:
udit@udit-Dabba ~/mec $ valgrind --leak-check=full
sendip -v -p ipv6 -f file.txt -6s ::1 -p esp -es 0x20 -eq 0x40
-ei z30 -eI z100 -p tcp -ts 21 -td 21 ::2
==4331== Memcheck, a memory error detector
==4331== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==4331== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==4331== Command: sendip -v -p ipv6 -f file.txt -6s ::1 -p esp -es 0x20
-eq 0x40 -ei z30 -eI …Run Code Online (Sandbox Code Playgroud) 可能重复:
C++错误:free():下一个大小无效(快):
这是一个C++问题(虽然是'C++被滥用'的问题).备选副本:面临错误:glibc检测到免费无效下一个大小(快)
我正在使用Linux工具生成一些n/w流量,但是当我尝试发送大于某个长度的数据时,当工具为其提供时,会出现此错误.
我的整个项目都介于两者之间.由于我没有创建该工具,因此不确定错误发生在哪里......并且此错误(偶数gdb)没有给出关于问题所在位置的任何提示.如何检测错误点?
如果有问题,我会给出一些问题的快照.请指导我该怎么办?它对我来说看起来像一个网格.
udit@udit-Dabba ~ $ sendip -v -p ipv6 -f file.txt -6s ::1 -p esp -es 0x20 -eq 0x40 -ei
abcd -eI zxc -p tcp -ts 21 -td 21 ::2 | more
*** glibc detected *** sendip: free(): invalid next size (normal): 0x09da25e8 ***
======= Backtrace: =========
/lib/i386-linux-gnu/libc.so.6(+0x6b961)[0x17b961]
/lib/i386-linux-gnu/libc.so.6(+0x6d28b)[0x17d28b]
/lib/i386-linux-gnu/libc.so.6(cfree+0x6d)[0x18041d]
/lib/i386-linux-gnu/libc.so.6(fclose+0x14a)[0x16b9ca]
/lib/i386-linux-gnu/libc.so.6(+0xe053f)[0x1f053f]
/lib/i386-linux-gnu/libc.so.6(__res_ninit+0x25)[0x1f0815]
/lib/i386-linux-gnu/libc.so.6(__res_maybe_init+0x130)[0x1f1810]
/lib/i386-linux-gnu/libc.so.6(__nss_hostname_digits_dots+0x34)[0x1f37d4]
/lib/i386-linux-gnu/libc.so.6(gethostbyname2+0x96)[0x1f82f6]
/usr/local/lib/sendip/ipv6.so(set_addr+0x2d)[0x3eec69]
sendip(main+0x8eb)[0x804a635]
/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x126e37]
sendip[0x8048f81]
======= Memory map: ========
00110000-0026a000 r-xp 00000000 08:07 3408705 /lib/i386-linux-gnu/libc-2.13.so
0026a000-0026b000 ---p 0015a000 …Run Code Online (Sandbox Code Playgroud) 我正在使用红帽企业版n尝试制作一个简单的php页面..
当我尝试...
// html code
<?php
echo exec(<cmd>);
?>
// rest html code
Run Code Online (Sandbox Code Playgroud)
它的工作正常
但是当试用......
// html code
<?php
exec(<cmd>);
?>
// rest html code
Run Code Online (Sandbox Code Playgroud)
它不起作用
即使像cat,ls等简单的命令也不起作用,我也尝试过2 > &1没有错误打印.
什么可能是错误???
我有这样的C结构......
struct icmp_prefixopt {
u_int8_t icmpopt_type;
u_int8_t icmpopt_len;
u_int8_t prefixlen;
u_int8_t lflag:1;
u_int8_t aflag:1;
u_int8_t reserved:6;
};
Run Code Online (Sandbox Code Playgroud)
我在同一个模块中为这样的成员提供了价值 -
popt= (struct icmp_prefixopt *)
malloc(sizeof(struct icmp_prefixopt));
popt->icmpopt_type = 3;
popt->icmpopt_len = 4;
popt->prefixlen = (u_int8_t)strtoul(arg, (char **)NULL, 0);
arg = index(arg, '+');
if (arg) {
++arg;
popt->lflag = ((u_int8_t)strtoul(arg, (char **)NULL, 0))&1;
}
arg = index(arg, '+');
if (arg) {
++arg;
popt->aflag = ((u_int8_t)strtoul(arg, (char **)NULL, 0))&1;
}
arg = index(arg, '+');
if (arg) {
++arg;
popt->reserved = 32; //((u_int8_t)strtoul(arg, (char …Run Code Online (Sandbox Code Playgroud) 这是显示单选按钮的代码的一小部分.
<table width="100%">
<tr>
<td style="text-align:center">
<input type="radio" name="ah" value="" id="ah" align="left" checked="checked" />AH
</td>
<td style="text-align:center">
<input type="radio" name="esp" value="none" id="esp" align="right"/>ESP
</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
问题是默认选中一个单选按钮(AH)如此处所述,当我点击其他单选按钮时,它也会被检查但现在两个都被检查我将如何禁用它们.我认为当我点击一个单选按钮时它会自动发生其他按钮应该自动禁用.请纠正我在哪里错了???
我有这样的C函数..
func(uint8_t *key,uint8_t keylen) {
FILE *fk;
fk=fopen("akey","wb");
fwrite((char *)key,keylen,1,fk);
puts((char *)key); // for testing
fclose(fk);
sprintf(sstring,"... \"%s\" ... ",(char *)key);
// ...other irrelevant stuff for here
system(sstring);
}
Run Code Online (Sandbox Code Playgroud)
我希望提供的键作为输入\"%s\"在sprintf命令中标记的位置使用
输入:
Key=qwerty
Run Code Online (Sandbox Code Playgroud)
输出:
$cat akey
qwerty
Run Code Online (Sandbox Code Playgroud)
和输出puts((char *)key)是 -
qwerty?
// include newline character as well
Run Code Online (Sandbox Code Playgroud)
建议我这个,我尝试了这个(在代码中各自的位置),但得到 segmentation fault
char *p;
memcpy(p,(char *)key,keylen);
puts((char *)p);
Run Code Online (Sandbox Code Playgroud) 我已经获得了一个已经正常工作的Makefile,它实际上工作正常.
Makefile内容可以在这篇文章中找到...
关于Makefile的问题 - 什么是"$ +"以及这里调用的.c文件/依赖项在哪里?
我从上面提到的上一篇文章中分别提出这个问题,因为它涉及一个不同的问题,并将其添加到该问题将不必要地增加其长度.
现在我添加了一个在很多地方经常使用的功能,所以我认为创建一个单独的文件将是一个不错的主意,所以我创建linklayer.c并添加linklayer.o到$LIBOBJS.
我加了这个......
LIBOBJS= linklayer.o csum.o compact.o protoname.o headers.o
parseargs.o cryptomod.o crc32.o
Run Code Online (Sandbox Code Playgroud)
还有这个
linklayer.o: linklayer.c
$(CC) -o $@ -c -I. $(CFLAGS) $+
Run Code Online (Sandbox Code Playgroud)
我已经声明了sendip_module.h已经在项目中存在的每个模块中声明和访问的函数.
但现在这个多重定义错误即将来临......我做错了什么或误解了什么?
注意: "ipv6_opts"在ipv6.h中定义
$ make all
for subdir in mec ; do \
cd $subdir ;\
make ;\
cd .. ;\
done
make[1]: Entering directory `/home/udit/Desktop/sendip-2.5-mec-2/mec'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/udit/Desktop/sendip-2.5-mec-2/mec'
gcc-4.4 -o ipv6.so -fPIC -fsigned-char -pipe …Run Code Online (Sandbox Code Playgroud)