#include
int main()
{
int sum2(int n);
int n,y;
printf("Input an integer number\n");
scanf("%d",&n);
y=sum2(n);
printf("sum is %d\n",y);
return 0;
}
int sum2(int n)
{
int f;
if(n=0)
f=0;
else
f=n+sum2(n-1);
return(f);
}

3个回答

#include
int sum2(int n);
int main()
{
int n,y;
printf("Input an integer number\n");
scanf("%d",&n);
y=sum2(n);
printf("sum is %d\n",y);
return 0;
}
int sum2(int n)
{
int f;
if(n=0)
f=0;
else
f=n+sum2(n-1);
return(f);
}

#include
int main()
{
int sum2(int n);
int n,y;
printf("Input an integer number\n");
scanf("%d",&n);
y=sum2(n);
printf("sum is %d\n",y);
return 0;
}
int sum2(int n)
{
int f;
if(n==0)
f=0;
else
f=n+sum2(n-1);
return(f);
}

#include
int sum2(int n);
int n,y;
printf("Input an integer number\n");
scanf("%d",&n);
y=sum2(n);
printf("sum is %d\n",y);
return 0;
int f;
if(n=0)
f=0;我没记错的话

#include <stdio.h> #include <stdlib.h> #include <string.h> void reverse( ); int main( ) { char str[100]; int start, end; gets(str); scanf("%d %d", &start, &end); reverse( str, start, end ); printf("%s\n", str); return 0; } void reverse(char str[],int start,int end){ int k,len; for(len=0;len<=100;len++){ if(str[len]=='\0'){ len--;break; } } if((end-start)>(len-start))end=len; if((end - start==0)||(end - start==1)){ k=str[end] ;str[end] = str[start] ;str[start] =k; } else{ k=str[end] ;str[end] = str[start] ;str[start] =k; reverse (str,start++,end--); //调试运行到这一步时进不了递归函数，提示错误为program received signal sigsegv,segmentation fault } }
Decv++调试报错 program received signal SIGSEGV,Segmentation fault

code blocks调试中出现 program ceceived signal SIGSEGV,Segmentation

Program received signal SIGSEGV, Segmentation fault. 0x000000332dc81484 in strncat () from /lib64/libc.so.6 之前并没有这个错误，但是我改了几个字符串之后就报错了，求助，在线等
C语言指针数组的strcpy命令使用错误，自学中，求解答
``` #include<stdio.h> #include<string.h> int main(){ char *t[3]={"ilovei","iloveb","ilovez"}; t[2]="dg"; printf("%s",t[2]); strcpy(t[2],"dg"); } ``` debug中发现 t[2]="dg";命令可以正常运行，但一运行 strcpy(t[2],"dg"); 就提示 program received signal SIGSEGV，sengmentaion fault. 这两行命令都是往指针数组的第二项进行进行赋值，第二条命令却不能执行。感到很费解，
socket snprintf()函数调用发生错误.
char str1[4096]; snprintf(str1, sizeof(str1), ":%s", sock_ntop((SA* )&cliaddr, clilen)); 我的目的就是想把sock_ntop转换的cliaddr ipv4地址前面加个冒号,然后复制到str1中,使最后的格式为str1 = ":127.0.0.1" 但是,这个函数调用总是出错,错误代码如下: Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7a60a03 in _IO_vfprintf_internal (s=s@entry=0x7fffffffbb30, format=<optimised out>, format@entry=0x401f18 ":%s", ap=ap@entry=0x7fffffffbc98) at vfprintf.c:1661 1661 vfprintf.c: No such file or directory. 整个程序代码好多,我就不贴了.

Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR)异常问题
2019-12-12 10:17:42.249 20460-20460/? A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x767385b0b3 in tid 20460 (app2.dfhon.com), pid 20460 (app2.dfhon.com) 2019-12-12 10:17:42.281 20486-20486/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 2019-12-12 10:17:42.281 20486-20486/? A/DEBUG: Build fingerprint: 'HUAWEI/ELE-AL00/HWELE:10/HUAWEIELE-AL00/10.0.0.173C00:user/release-keys' 2019-12-12 10:17:42.281 20486-20486/? A/DEBUG: Revision: '0' 2019-12-12 10:17:42.281 20486-20486/? A/DEBUG: ABI: 'arm64' 2019-12-12 10:17:42.281 20486-20486/? A/DEBUG: SYSVMTYPE: Maple APPVMTYPE: Art 2019-12-12 10:17:42.281 20486-20486/? A/DEBUG: Timestamp: 2019-12-12 10:17:42+0800 2019-12-12 10:17:42.281 20486-20486/? A/DEBUG: pid: 20460, tid: 20460, name: app2.dfhon.com >>> app2.dfhon.com <<< 2019-12-12 10:17:42.281 20486-20486/? A/DEBUG: uid: 10152 2019-12-12 10:17:42.281 20486-20486/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x767385b0b3 2019-12-12 10:17:42.281 20486-20486/? A/DEBUG: x0 0000000000000004 x1 000000767385b0b0 x2 0000000000000004 x3 0000000000000004 2019-12-12 10:17:42.281 20486-20486/? A/DEBUG: x4 000000000000006c x5 0000007ff2ce4428 x6 6dff7e7e7e7e7e7e x7 7f7f7f7f7f7f7f7f 2019-12-12 10:17:42.281 20486-20486/? A/DEBUG: x8 000000767385b0b4 x9 000000767385b0b3 x10 000000761256b000 x11 0000000000000001 2019-12-12 10:17:42.281 20486-20486/? A/DEBUG: x12 00000075919f39e8 x13 00000075919f39e0 x14 0000000000000001 x15 aaaaaaaaaaaaaaab 2019-12-12 10:17:42.281 20486-20486/? A/DEBUG: x16 000000761486d938 x17 0000007614861950 x18 00000076177d8000 x19 0000007580ffe000 2019-12-12 10:17:42.281 20486-20486/? A/DEBUG: x20 0000000000000000 x21 0000007591850540 x22 000000757a86cb00 x23 00000076171d2020 2019-12-12 10:17:42.281 20486-20486/? A/DEBUG: x24 0000007580f534e0 x25 00000075918f5000 x26 00000075890acb80 x27 0000007591850540 2019-12-12 10:17:42.281 20486-20486/? A/DEBUG: x28 0000000000000081 x29 0000007ff2ce4560 2019-12-12 10:17:42.281 20486-20486/? A/DEBUG: sp 0000007ff2ce44c0 lr 0000007580e895e8 pc 0000007580e8990c 2019-12-12 10:17:42.304 707-707/? E/WifiHAL: enter wifi_get_link_stats 2019-12-12 10:17:42.305 1352-1787/system_process E/WificondControl: Noise: 0, Snr: -83, Chload: 127 2019-12-12 10:17:42.317 20486-20486/? A/DEBUG: backtrace: 2019-12-12 10:17:42.317 20486-20486/? A/DEBUG: #00 pc 00000000000d490c <anonymous:7580db5000> 程序一启动就直接退出 测试机 华为P30，Android10.0系统，请问如何查找问题所在，如何处理呢？

6 int main(void) { (gdb) n 7 char arr[] = "hello"; (gdb) n 8 char *p = "world"; (gdb) n 9 printf("pid:%d\n",getpid()); (gdb) n pid:10709 10 printf("&arr:%p\n&p:%p\nworld:%p\nhello:%p\n",&arr,&p,p,"hello"); (gdb) n &arr:0x7fffffffdff0 &p:0x7fffffffdfe8 world:0x400810 hello:0x400841 11 printf("arr:%s\n",arr); (gdb) n arr:hello 12 printf("p:%s\n",p); (gdb) n p:world 13 strcpy(p,arr); (gdb) n Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7ab14e6 in ?? () from /lib/x86_64-linux-gnu/libc.so.6 (gdb) n Cannot find bounds of current function (gdb) n 0x00007ffff7ab14e6这个地址是什么意思，这个是虚拟地址？系统想告诉我这个虚拟地址没有对应的物理地址？

android开发，遇到了Fatal signal 11 (SIGSEGV)

Linux下MPI+OpenMP程序编译运行出错

A/libc: Fatal signal 11 (SIGSEGV)
android程序中运行C++库时出现如下问题，求高手解决： 02-10 16:49:09.335 9874-9874/imeeting.shiheng.com.imeeting A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0xe0 in tid 9874 (ng.com.imeeting) 02-10 16:49:09.335 1080-3166/? D/LocationManagerService: getLastLocation: Request[ACCURACY_FINE gps requested=0 fastest=0 num=1] 02-10 16:49:09.365 296-296/? E/SMD: DCD ON 02-10 16:49:09.445 980-980/? I/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 02-10 16:49:09.445 980-980/? I/DEBUG: Build fingerprint: 'samsung/hltezm/hlte:5.0/LRX21V/N9008VZMUDPA2:user/release-keys' 02-10 16:49:09.445 980-980/? I/DEBUG: Revision: '12' 02-10 16:49:09.445 980-980/? I/DEBUG: ABI: 'arm' 02-10 16:49:09.455 980-980/? I/DEBUG: pid: 9874, tid: 9874, name: ng.com.imeeting >>> imeeting.shiheng.com.imeeting <<< 02-10 16:49:09.455 980-980/? I/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xe0 02-10 16:49:09.475 980-980/? I/DEBUG: r0 000000e0 r1 b3ae507c r2 00000001 r3 000fffff 02-10 16:49:09.475 980-980/? I/DEBUG: r4 000000e0 r5 00000000 r6 000000e0 r7 b6fd5fd8 02-10 16:49:09.475 980-980/? I/DEBUG: r8 b6fe1fb8 r9 b3ae507c sl 00000000 fp 00000003 02-10 16:49:09.475 980-980/? I/DEBUG: ip b3a00000 sp be912c68 lr b6fbbb47 pc b6f8428a cpsr 200f0030 02-10 16:49:09.475 980-980/? I/DEBUG: backtrace: 02-10 16:49:09.475 980-980/? I/DEBUG: #00 pc 0001428a /system/lib/libc.so (pthread_mutex_lock+7) 02-10 16:49:09.475 980-980/? I/DEBUG: #01 pc 0004bb43 /system/lib/libc.so (je_tcache_bin_flush_small+78) 02-10 16:49:09.475 980-980/? I/DEBUG: #02 pc 0004be05 /system/lib/libc.so (je_tcache_event_hard+52) 02-10 16:49:09.475 980-980/? I/DEBUG: #03 pc 00046525 /system/lib/libc.so (ifree+688) 02-10 16:49:09.475 980-980/? I/DEBUG: #04 pc 0000fa2b /system/lib/libc.so (free+10) 02-10 16:49:09.475 980-980/? I/DEBUG: #05 pc 0000d7e7 /system/lib/libutils.so (android::SharedBuffer::dealloc(android::SharedBuffer const*)+6) 02-10 16:49:09.475 980-980/? I/DEBUG: #06 pc 00010053 /system/lib/libutils.so (android::VectorImpl::_shrink(unsigned int, unsigned int)+154) 02-10 16:49:09.475 980-980/? I/DEBUG: #07 pc 00010f0b /system/lib/libutils.so (android::Looper::pollInner(int)+74) 02-10 16:49:09.475 980-980/? I/DEBUG: #08 pc 0001114d /system/lib/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+92) 02-10 16:49:09.475 980-980/? I/DEBUG: #09 pc 00082e61 /system/lib/libandroid_runtime.so (android::NativeMessageQueue::pollOnce(_JNIEnv*, int)+22) 02-10 16:49:09.475 980-980/? I/DEBUG: #10 pc 000b229f /system/framework/arm/boot.oat 02-10 16:49:09.895 980-980/? W/libbacktrace: virtual bool Backtrace::VerifyReadWordArgs(uintptr_t, word_t*): invalid pointer 0x131 02-10 16:49:10.025 980-980/? I/DEBUG: Tombstone written to: /data/tombstones/tombstone_08 [ 02-10 16:49:10.025 980: 980 E/ ] ro.product_ship = true [ 02-10 16:49:10.025 980: 980 E/ ] ro.debug_level = 0x4f4c 02-10 16:49:10.025 4969-4969/? E/audit: type=1701 msg=audit(1486716550.025:282): auid=4294967295 uid=10419 gid=10419 ses=4294967295 subj=u:r:untrusted_app:s0 pid=9874 comm="ng.com.imeeting" reason="memory violation" sig=11 02-10 16:49:10.035 1080-9095/? E/SharedPreferencesImpl: Couldn't create directory for SharedPreferences file shared_prefs/log_files.xml
Java学习的正确打开方式

linux系列之常用运维命令整理笔录

Python十大装B语法
Python 是一种代表简单思想的语言，其语法相对简单，很容易上手。不过，如果就此小视 Python 语法的精妙和深邃，那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点，并附上详细的实例代码。如能在实战中融会贯通、灵活使用，必将使代码更为精炼、高效，同时也会极大提升代码B格，使之看上去更老练，读起来更优雅。

Docker 技术发展为微服务落地提供了更加便利的环境，使用 Docker 部署 Spring Boot 其实非常简单，这篇文章我们就来简单学习下。首先构建一个简单的 S...

SQL-小白最佳入门sql查询一

redis分布式锁，面试官请随便问，我都会

Nginx 原理和架构
Nginx 是一个免费的，开源的，高性能的 HTTP 服务器和反向代理，以及 IMAP / POP3 代理服务器。Nginx 以其高性能，稳定性，丰富的功能，简单的配置和低资源消耗而闻名。 Nginx 的整体架构 Nginx 里有一个 master 进程和多个 worker 进程。master 进程并不处理网络请求，主要负责调度工作进程：加载配置、启动工作进程及非停升级。worker 进程负责处...
“狗屁不通文章生成器”登顶GitHub热榜，分分钟写出万字形式主义大作

《程序人生》系列-这个程序员只用了20行代码就拿了冠军

11月8日，由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办，科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。 　　区块链技术被认为是继蒸汽机、电力、互联网之后，下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力，电力解决了人类基本的生活需求，互联网彻底改变了信息传递的方式，区块链作为构造信任的技术有重要的价值。 　　1...
Java世界最常用的工具类库
Apache Commons Apache Commons有很多子项目 Google Guava 参考博客

【技巧总结】位运算装逼指南

Android 9.0 init 启动流程