My outcome has two double quotation marks, I don't know why.


  • 0
    K
    char* addBinary(char* a, char* b) {
    int i,j,al,bl,as=0,bs=0,cs=0;
    char* c;
    al=sizeof(a);
    bl=sizeof(b);
    for(i=0;i++;i<al)
    {
        if(a[i]=='1')
        as=as+pow(2,al-(i+1));
    }
    for(i=0;i++;i<bl)
    {
        if(b[i]=='1')
        bs=bs+pow(2,bl-(i+1));
    }
    cs=as+bs;
    for(i=0;i++;i<8)
    {
        if(cs>pow(2,8-i))
        {
            c[i]='1';
        }
        else
        {
            c[i]='0';
        }
        cs=cs-pow(2,8-i);
    }
    return c;
    

    }

    My answer is wrong, and I don't know why. I am a new guy, can anybody help me solve this problem? Thanks very much.


Log in to reply
 

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