Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to convert the string type of C language into integer or floating-point type?
How to convert the string type of C language into integer or floating-point type?
The form conversion of large numbers needs to implement an extension method by itself.

Two days ago, I just helped another person realize the conversion of a decimal number character from 100 to 16:

# Contains? & ltstdio.h & gt

# Contains? & ltstring.h & gt

# Contains? & ltstdlib.h & gt

# Definition? is digit(c)(' 0 '? & lt=? (3)? & amp& amp? (3)? & lt=? '9')

# Definition? Maximum number of DIGI? 100

int? _div_ 16(char? * large _ number,? int? *p_size)

{

int? to_div? =? 0;

Charles? *div? =? big _ num

int? num _ size

Charles? :: Current situation;

int? Rem? =? 0,quo_size? =? 0; ;

And (0? ==? *(div)){ div++; ? (* p _ size)-; }

num_size? =? * p _ size

if(num_size? ==? 0? ||? num_size? ==? 1){

*p_size? =? 0;

Rem? =? div[0];

div[0]? =? 0;

Return? rem

}

quo? =? malloc(num _ size);

memset(quo,0,num _ size);

while(num _ size & gt; 0){

to_div? =? rem* 10? +? * div

quo[quo_size]? =? to _ div/ 16;

Rem? =? to _ div % 16;

quo _ size++;

num _ size-;

div++;

}

memcpy(big_num,quo,quo _ size);

* p _ size = quo _ size

Free (quo);

Return? rem

}

int? Master ()

{

Charles? Enter [Maximum DIGI Quantity]? =? {0};

Charles? num[MAX_DIGI_NUM+ 1]? =? {0};

Charles? Hexadecimal [MAX _ DIGI _ number+1]? =? {0};

int? I,num_size,result

Printf ("input? December? num:");

Scanf("%s ",input);

Memcpy (quantity, input, maximum _ DIGI _ quantity);

Me? =? num_size? =? Strlen (number);

If (me? & gt=? Maximum number of DIGI) {

Printf ("input? num? Is it? Also? Big! \ n ");

Return? 0;

}

while(i - ){

If (! is digit(num[I]){

Printf ("input? num? Is it? Isn't it? Effective! \ n ");

Return? 0;

}

num[i]? =? Atoy (&num [I]);

}

Charles? *tmp? =? & hexadecimal [maximum DIGI number];

While (quantity size)

{

The result? =? _div_ 16 (No.,&num _ size);

tmp-;

If (the result? & lt=? 9)

*tmp? =? 0x30? +? Results;

other

*tmp? =? 0x60? +? Result-9;

}

printf("Hex? num? Is it? 0x%s\n ",tmp);

}