Good day! Can I ask how to convert a string to int in turbo C. For example:
void comp()
{
    FILE *fp;
    int i,x;
    long int deci;
    char bin[8];
    char *str=0;
    char buf[1024];
    fp=fopen("C:\enc.txt","w");
    printf("Enter a text: ");
    scanf("%[^\n]",str);
    init(str);
    for(i=0;i<128;i++)
    {
        if(code[i])
        {
            printf("'%c': %s\n",i, code[i]);
        }
    }
I'm making a binary code here with the use of string.
    encode(str, buf);
    deci=decimal(buf);
    printf("%li", deci);
    fprintf(fp,"%s",deci);
    fclose(fp);
}
Here is the function decimal()
int decimal(long int decimal)
{
    int dc, power;
    power=1;
    ht=0;
    while(decimal>0)
    {
        dc+=decimal%10*power;
        decimal=decimal/10;
        power=power*2;
    }
    return dc;
}
Thanks for the responses!
 
     
    