獲得雙值I有一個C
方案產生或填充炭的載體中包含的字符串:從字符串
.........................
char value[160]
double* d = NULL;
char * pEnd = NULL;
......................................
與填充值RX之後:551.54 455.61 98
我向得到這個雙重價值, 這裏我已經試過:
printf(" the string value is %s \n",value); // works fine
for (i = 0; i<3 ;i++) {
if(i ==0)
d[i] = strtod(value,&pEnd);
else
d[i] =strtod(pEnd,&pEnd);
printf(" the value of d is %lf\n",d[i]);
}
程序與Segmentation fault
錯誤崩潰。任何想法我可以如何解決這個問題? 在此先感謝
char * pEnd = NULL; ? 另外,使用malloc()或calloc()指針。 – Igor 2014-08-27 14:07:11
請發表真實的代碼。 'char * pEnd = = NULL;'也不會爲(i = o:i <3; i ++)'編譯。 – interjay 2014-08-27 14:09:49
@interjay真正的代碼和彙編不是一個程序我沒有得到任何錯誤 – Engine 2014-08-27 14:16:31