Delete a digit in C

Im sorry if i shouldnt post C related stuff here, I dont like stack overflow so i wanted to try my luck here.

Anyways, I am soposed to return an integer with 1 deleted digit so that i get the maximum possible number.
Its specified that 10 <= n <= 1000000
input 134 output 34 exp: removed 1, 34 is left, removing 3 would output 14, removing 4 would output 13 34 > 14 > 13.

input 1001 output 101 …
My code so far:

#include <math.h>
#include <stdbool.h>
int deleteDigit(int n) {
    char number[7];
    int lenght = log10(n) + 1; //For any positive integer nn, the number of digits in n is log(base10)n +1
    int result,i,j = 0;    
    bool hasZero = false;
    sprintf(number, "%d", n); 
        while(hasZero == false || j < lenght)
            if(number[j++] == '0') hasZero = true;
            for(i = 1; i<lenght;i++)
             result += number[i] - '0';
             result *= 10;
            } else if (hasZero)
            for(i = 0; i<lenght;i++)
            if(i == j) i++;
             result += number[i] - '0';
             result *= 10;
        return result/10;

I would like to ask you some questions:

  1. Does this even compile without any errors?
    I don’t want to be mean here but if this in fact C it looks like it’s lacking “{ }” brackets in some important places.

  2. what is your reasoning for your algorithm and pseudo code?
    Explaining someone else line by line your reasoning or a “rubber ducky” might help you clarify your doubts.

  3. what is the specific doubt in this case?

It compiles, it just gives a wrong output.
The {} is missing where it just has to execute the next line of the code in the loop(and only that line), that’s not an error.
The algo checks if the number has a 0 digit, if it doesn’t it removes the first digit (the first digit of 1564 would be 1) if it does have a 0 it removes the first 0 in the number by just skipping the number[index] where it found the 0 ( the if(i == j) i++; ).

At smaller numbers it returns the whole input, at bigger numbers it returns a random integer, sometimes negative.

And i just realized the algorithm is very very wrong.