samedi 27 juin 2015

strcpy Signal SIGABRT

I know it's a common question but I didn't find a suitable explanation yet! My project compiles but I keep getting the Thread: signal SIGABRT! - the strcpy function; nothing's written in the debugger window and when I debug step by step the test works perfectly fine and I get success, but when I try to run it again I get that error! How can I fix it?

here's my code :

static char* copyMember(const char* str){
    if(str==NULL){
        return NULL;
    }
    char* newStr=malloc((strlen(str)+1)*sizeof(char));
    if(newStr==NULL){
        return NULL;
    }
    return strcpy(newStr, str);
}

Aucun commentaire:

Enregistrer un commentaire