阅读背景:

(char*)malloc(sizeof(char))导致分割错误,如何?

来源:互联网 

The code works fine on most inputs, but for userID's whih are very long I get a segmentation fault. My question is, how can malloc cause a segmentation fault? simply allocating memory shouldn't cause this. I found the problem area by using printf() statements, it seem the malloc within my read_line() function is where the problem is because the second "read_line" does not print, but the first before the malloc does. The code works fine on most inputs, but for use




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: