| 2 | 1/1 | 返回列表 |
| 查看: 810 | 回復(fù): 1 | ||
13659938271鐵蟲 (初入文壇)
|
[求助]
這個(gè)是gdb調(diào)試錯(cuò)誤代表什么意思 已有1人參與
|
|
Program received signal SIGSEGV, Segmentation fault. 0x00684867 in __strcmp_sse4_2 () from /lib/libc.so.6 上面這句是什么意思 程序如下: 再?zèng)]有調(diào)用add_specie的時(shí)候可以運(yùn)行,但是一旦調(diào)用就出現(xiàn)了段錯(cuò)誤 #include<stdio.h> #include<stdlib.h> #include<string.h> #define MAX_LINE 500 #define MAX_REACTIONS 6046 #define MAX_SPECIES 5000 #define MAX_CHAR_SPECIES 32 void add_specie (char *new_specie, char *species[],int *n_species) { int i; if (strcmp (new_specie, "") == 0) return; for (i = 0; i < *n_species; i++) { if (strcmp (species, new_specie) == 0) return; } i = *n_species; if (i < MAX_SPECIES ) { if (strlen (new_specie) < MAX_CHAR_SPECIES - 1) { strcpy (species, new_specie); (*n_species)++; } } return; } int main() { //struct react reactions[MAX_REACTIONS]; const char *osu2009; FILE *f; char line[MAX_LINE]; int line_number=0; char reactant1[MAX_CHAR_SPECIES]; char reactant2[MAX_CHAR_SPECIES]; char reactant3[MAX_CHAR_SPECIES]; char product1[MAX_CHAR_SPECIES]; char product2[MAX_CHAR_SPECIES]; char product3[MAX_CHAR_SPECIES]; char product4[MAX_CHAR_SPECIES]; double alpha; double beta; double gamma; int reaction_type; int reaction_no; char *species[MAX_SPECIES]; int *n_species; if((f=fopen("osu2009.chm","r"))==NULL) { printf("can not open\n"); exit(0); } while(fgets(line,MAX_LINE,f)!=NULL) { line_number++; if (line[0]=='#') continue; strcpy (reactant1, ""); strcpy (reactant2, ""); strcpy (reactant3, ""); strcpy (product1, ""); strcpy (product2, ""); strcpy (product3, ""); strcpy (product4, ""); alpha = 0; beta = 0; gamma = 0; reaction_type = 0; //付初始值 reaction_no = 0; if ((sscanf (line, "%s -> %s %lf %lf %lf %d %d",reactant1, product1, &alpha, &beta, &gamma, &reaction_type, &reaction_no) == 7) ||(sscanf (line, "%s + %s -> %s + %s %lf %lf %lf %d %d",reactant1, reactant2, product1, product2,&alpha, &beta, &gamma, &reaction_type, &reaction_no) == 9) ||(sscanf (line, "%s + %s -> %s %lf %lf %lf %d %d",reactant1, reactant2, product1, &alpha, &beta, &gamma, &reaction_type, &reaction_no) == 8) ||(sscanf (line, "%s + %s -> %s + %s + %s %lf %lf %lf %d %d",reactant1, reactant2, product1, product2, product3,&alpha, &beta, &gamma, &reaction_type, &reaction_no) == 10) || (sscanf (line, "%s + %s -> %s + %s + %s + %s %lf %lf %lf %d %d",reactant1, reactant2, product1, product2, product3,product4,&alpha, &beta, &gamma, &reaction_type, &reaction_no) == 11) ||(sscanf (line, "%s + %s + %s -> %s + %s %lf %lf %lf %d %d",reactant1, reactant2, reactant3, product1, product2,&alpha, &beta, &gamma, &reaction_type, &reaction_no) == 10)); if ((strcmp (reactant1, "cosmic-ray") == 0) || (strcmp (reactant1, "uv-photon") == 0) || (strcmp (reactant1, "photon") == 0)) { strcpy (reactant1, reactant2); strcpy (reactant2, reactant3); strcpy (reactant3, ""); } if ((strcmp (reactant2, "cosmic-ray") == 0) || (strcmp (reactant2, "uv-photon") == 0) || (strcmp (reactant2, "photon") == 0)) { strcpy (reactant2, reactant3); strcpy (reactant3, ""); } if ((strcmp (reactant3, "cosmic-ray") == 0) || (strcmp (reactant3, "uv-photon") == 0) || (strcmp (reactant3, "photon") == 0)) { strcpy (reactant3, ""); } if ((strcmp (product1, "cosmic-ray") == 0) ||(strcmp (product1, "uv-photon") == 0) || (strcmp (product1, "photon") == 0)) { strcpy (product1, product2); strcpy (product2, product3); strcpy (product3, product4); strcpy (product4, ""); } if ((strcmp (product2, "cosmic-ray") == 0) || (strcmp (product2, "uv-photon") == 0) || (strcmp (product2, "photon") == 0)) { strcpy (product2, product3); strcpy (product3, product4); strcpy (product4, ""); } if ((strcmp (product3, "cosmic-ray") == 0) || (strcmp (product3, "uv-photon") == 0) || (strcmp (product3, "photon") == 0)) { strcpy (product3, product4); strcpy (product4, ""); } if ((strcmp (product4, "cosmic-ray") == 0) || (strcmp (product4, "uv-photon") == 0) || (strcmp (product4, "photon") == 0)) { strcpy (product4, ""); } add_specie (reactant1, species, n_species); add_specie (reactant2, species, n_species); add_specie (reactant3, species, n_species); add_specie (product1, species, n_species); add_specie (product2, species, n_species); add_specie (product3, species, n_species); add_specie (product4, species, n_species); // printf("reactant1:%s reactant2:%s reactant3:%s product1:%s product2:%s product3:%s product4:%s alpha:%.2e beta:%.2e gamma:%e reaction_type:%d reaction_no: %d\n",reactant1,reactant2,reactant3,product1,product2,product3,product4,alpha,beta,gamma,reaction_type,reaction_no); } fclose(f); return 0; } |

金蟲 (小有名氣)

| 2 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 化學(xué)0703 調(diào)劑 306分 一志愿211 +4 | 26要上岸 2026-03-28 | 4/200 |
|
|---|---|---|---|---|
|
[考研] 286求調(diào)劑 +12 | PolarBear11 2026-03-26 | 12/600 |
|
|
[考研] 331環(huán)境科學(xué)與工程求調(diào)劑 +3 | 熠然好運(yùn)氣 2026-03-27 | 3/150 |
|
|
[考研] 求調(diào)劑 +4 | 零八# 2026-03-27 | 4/200 |
|
|
[考研] 安徽大學(xué)專碩生物與醫(yī)藥專業(yè)(086000)324分,英語(yǔ)已過四六級(jí),六級(jí)521,求調(diào)劑 +4 | 美味可樂雞翅 2026-03-26 | 4/200 |
|
|
[考研] 274求調(diào)劑 +17 | 顧九笙要謙虛 2026-03-24 | 23/1150 |
|
|
[考研] 085600材料與化工調(diào)劑 +10 | A-哆啦Z夢(mèng) 2026-03-23 | 16/800 |
|
|
[考研] 085600,材料與化工321分調(diào)劑 +4 | 大饞小子 2026-03-27 | 6/300 |
|
|
[考研] 303求調(diào)劑 +7 | 安憶靈 2026-03-22 | 8/400 |
|
|
[考研] 0703化學(xué)一志愿南京師范大學(xué)303求調(diào)劑 +3 | zzffylgg 2026-03-24 | 3/150 |
|
|
[考研] 292求調(diào)劑 +4 | 求求了收下我吧?/a> 2026-03-26 | 4/200 |
|
|
[考研] 一志愿吉大071010,316分求調(diào)劑 +3 | xgbiknn 2026-03-27 | 3/150 |
|
|
[考研] 359求調(diào)劑 +4 | 王了個(gè)楠 2026-03-25 | 4/200 |
|
|
[考研] 081200-11408-276學(xué)碩求調(diào)劑 +3 | 崔wj 2026-03-26 | 3/150 |
|
|
[考研] 一志愿211 初試270分 求調(diào)劑 +6 | 谷雨上岸 2026-03-23 | 7/350 |
|
|
[考研] 291 求調(diào)劑 +7 | 化工2026屆畢業(yè)?/a> 2026-03-21 | 8/400 |
|
|
[考研] 材料專碩 335 分求調(diào)劑 +4 | 拒絕冷暴力 2026-03-25 | 4/200 |
|
|
[考研] 285求調(diào)劑 +3 | AZMK 2026-03-24 | 3/150 |
|
|
[考研] 344求調(diào)劑 +3 | desto 2026-03-24 | 3/150 |
|
|
[考博] 26申博自薦 +3 | whh869393 2026-03-24 | 3/150 |
|