gccsegmentation-faulttrim

GCC : Segmentation Fault from Trim function


I got a gcc "Segmentation Fault" error with this script : http://paste2.org/p/1397204, why ?

I tested this code with Visual C++ compiler and I don't get any error...


Solution

  • Thanks to MByD according to Getting Segmentation Fault topic.

    Replace :

    printf("|%s|\n", trim("  MyStringHaveToBeTrimmed  "));
    

    With :

    char str[] = "  MyStringHaveToBeTrimmed  ";
    printf("|%s|\n", trim(str));
    

    New code : http://paste2.org/p/1397248