Tag: 故障

为什么我在下面的代码中出现分段错误?

我有一个txt文件,我只想获得大于12个字符的行。 将这些行插入名为graph_node的图形变量中。 txt文件: 1,”execCode(workStation,root)”,”OR”,0 2,”RULE 4 (Trojan horse installation)”,”AND”,0 3,”accessFile(workStation,write,’/usr/local/share’)”,”OR”,0 4,”RULE 16 (NFS semantics)”,”AND”,0 5,”accessFile(fileServer,write,’/export’)”,”OR”,0 6,”RULE 10 (execCode implies file access)”,”AND”,0 7,”canAccessFile(fileServer,root,write,’/export’)”,”LEAF”,1 6,7,-1 图节点类型: #ifndef Graph_Structure #define Graph_Structure struct Graph_Node{ char id[50]; char node_name[50]; struct Graph_Node* next; struct Graph_Node* edges; }; typedef struct Graph_Node graph_node; #endif 这是将数据插入图形变量的方法: void insert_node(graph_node** node, graph_node* data){ printf(“\nINSERTING\n”); graph_node* temp […]

ARM Cortex-M处理器硬故障处理中的冗余代码

来自FreeRTOS.org ,关于在ARM Cortex-M3和ARM Cortex-M4微控制器上调试硬故障和其他exception ,根据FreeRTOS的人员,我们可以使用以下代码来调试ARM Cortex-M硬故障 – /* The fault handler implementation calls a function called prvGetRegistersFromStack(). */ static void HardFault_Handler(void) { __asm volatile ( ” tst lr, #4 \n” ” ite eq \n” ” mrseq r0, msp \n” ” mrsne r0, psp \n” ” ldr r1, [r0, #24] <======== NOTE THIS LINE \n" " […]

localtime() – 分段错误

我有这个代码从“29-02-2016”之类的日期返回工作日,但有时它会在本地时间(&t)给出分段错误。 int obterDiaSemana(char *str) { struct tm tm2; if(strptime(str, “%d-%m-%Y”, &tm2) != NULL) { time_t t = mktime(&tm2); return localtime(&t)->tm_wday; //Sunday=0, Monday=1, etc. } return -1; } 该函数收到: char userDate[10]=”29-02-2016″; 我一直在寻找解决方案,但无法解决这个问题。 提前致谢。 如果您需要一些其他信息,请告诉我。

C中的分段错误(核心转储)错误

我正在尝试编写一个C程序来求和并减去两个复数。 这是代码: #include #include typedef struct cplx { int re; int im; } cplx; cplx* sum(cplx *x, cplx *y,int n) { cplx *z; int i; for(i=0;i<n;i++) { z[i].re=x[i].re+y[i].re; z[i].im=x[i].im+y[i].im; } return z; } cplx* difference(cplx *x, cplx *y, int n) { cplx *z; int i; for(i=0;i<n;i++) { z[i].re=x[i].re-y[i].re; z[i].im=x[i].im-y[i].im; } return z; } cplx* sumdiff(cplx […]