For the first time on the Liunx (Liunx Mint 17) using GCC to compile C files, unexpectedly prompted "Can't find Stdio.h", after Google found that execution
sudo Install build-essential
Can, see: http://slipper-99933.blog.163.com/blog/static/39954044201021651833785/
Body:
? Just learned the flexible array, according to the tutorial wrote a flexible array to generate the Fibonacci sequence, after a change after the GCC compiler passed, the runtime is prompted "segment error." Google says it is most likely a memory access error caused by the array Nearúdtoúd interface. A careful examination is due to access to an unassigned pointer.
? To avoid such problems after all the definition of pointers are initialized first, but also strict attention to the pointer before the value of access.
?
? Before modification:
typedefstruct_soft_array{intLen; intarray[];} Softarray;softarray* Create_soft_array (intsize) {Softarray*ret; RET->len =size; if(Size >0 ) { returnret = (softarray*) malloc (sizeof(*ret) +sizeof(int)*size); } returnRET =NULL;}
? After modification:
typedef struct _soft_array{ int Len; int array[];} Softarray;softarray * Create_soft_array (int size) {softarray * ret = NULL; if (Size > 0 = (softarray*) malloc (sizeof (*ret) + sizeof (int ) *size); RET ->len = size; return ret;}
date:2014-10-25
GCC compile, run but show "segment error" Workaround