Runtime Erro On C


  • 0
    L

    char* reverseString(char* s)
    {
    int i=0;
    char * rs = (char*)malloc(sizeof(s)+1);

    for (i =strlen(s)-1;i >= 0;i--)
    {
    	*rs= *(s + i);
    	 rs++;
    }
    *rs = '\0';
    rs=rs-strlen(s);
    
    return rs;
    

    }

    I can't find what happend to
    "A man
    a plan
    a canal: Panama"


  • 0
    L

    sizeof->strlen


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.