#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX_LINE 500
double strtodouble ( char * array[ MAX_LINE] , int position) {
static char temp[ MAX_LINE] ;
int i, pos_temp = 0 ;
for ( i = 0 ; array[ i] != '\0 ' ; ++ i) {
if ( array[ position] [ i] == ',' ) {
temp[ pos_temp++ ] = '.' ;
}
else if ( array[ position] [ i] != '.' ) {
temp[ pos_temp++ ] = array[ position] [ i] ;
}
}
temp[ pos_temp] = '\0 ' ;
}
int main( void )
{
char sFrase[ ] = "1337-000/2018 01/10/2018 KI BARATO MERCEARIA DE DESCONT SECRETARIA DA CAMARA SECRETARIA DA CAMARA AÇÃO LEGISLATIVA Dispensa - Isento Compras e Serviços 2.343,50 343,40 343,30" ;
int count = 0 ;
char * p
= strtok ( sFrase
, " " ) ; char * array[ 500 ] ;
//float valor = atof(*array);
double num1, num2, num3;
while ( p)
{
array[ count] = p;
count++;
}
//printf("%s\n", array[cont-1]);
//printf("%s\n", array[cont-2]);
//printf("%s\n", array[cont-3]);
//array[cont-3] = 343,50
//ptr=array[cont-3][3]
num1 = strtodouble( array, count- 3 ) ;
printf ( "\n ESTE É O VALOR EMPENHADO --> %2.2f" , num1
) ;
num2 = strtodouble( array, count- 2 ) ;
printf ( "\n ESTE É O VALOR LiQUIDADO --> %2.2f" , num2
) ;
num3 = strtodouble( array, count- 1 ) ;
printf ( "\n ESTE É O VALOR PAGO --> %2.2f\n " , num3
) ;
return 0 ;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KI2luY2x1ZGUgPHN0ZGxpYi5oPgoKI2RlZmluZSBNQVhfTElORSA1MDAKCmRvdWJsZSBzdHJ0b2RvdWJsZSAoY2hhciAqYXJyYXlbTUFYX0xJTkVdLCBpbnQgcG9zaXRpb24pewogICAgc3RhdGljIGNoYXIgdGVtcFtNQVhfTElORV07CiAgICBpbnQgaSwgcG9zX3RlbXAgPSAwOwogICAgZm9yIChpID0gMDsgYXJyYXlbaV0gIT0gJ1wwJzsgKytpKXsKICAgICAgICBpZiAoYXJyYXlbcG9zaXRpb25dW2ldID09ICcsJyl7CiAgICAgICAgICAgIHRlbXBbcG9zX3RlbXArK10gPSAnLic7CiAgICAgICAgfQogICAgICAgIGVsc2UgaWYgKGFycmF5W3Bvc2l0aW9uXVtpXSAhPSAnLicpewogICAgICAgICAgICB0ZW1wW3Bvc190ZW1wKytdID0gYXJyYXlbcG9zaXRpb25dW2ldOwogICAgICAgIH0KICAgIH0KICAgIHRlbXBbcG9zX3RlbXBdID0gJ1wwJzsKCiAgICByZXR1cm4gYXRvZih0ZW1wKTsKfQoKaW50IG1haW4odm9pZCkKewoKICAgIGNoYXIgc0ZyYXNlW109IjEzMzctMDAwLzIwMTggMDEvMTAvMjAxOCBLSSBCQVJBVE8gTUVSQ0VBUklBIERFIERFU0NPTlQgU0VDUkVUQVJJQSBEQSBDQU1BUkEgU0VDUkVUQVJJQSBEQSBDQU1BUkEgQcOHw4NPIExFR0lTTEFUSVZBIERpc3BlbnNhIC0gSXNlbnRvIENvbXByYXMgZSBTZXJ2acOnb3MgMi4zNDMsNTAgMzQzLDQwIDM0MywzMCI7CiAgICBpbnQgY291bnQgPSAwOwogICAgY2hhciAqcCA9IHN0cnRvayhzRnJhc2UsICIgIik7CiAgICBjaGFyICphcnJheVs1MDBdOwogICAgLy9mbG9hdCB2YWxvciA9IGF0b2YoKmFycmF5KTsKICAgIGRvdWJsZSBudW0xLCBudW0yLCBudW0zOwoKICAgIHdoaWxlIChwKQogICAgewogICAgICAgIGFycmF5W2NvdW50XSA9IHA7CgogICAgICAgIHAgPSBzdHJ0b2sgKE5VTEwsICIgIik7CgogICAgICAgIGNvdW50Kys7CiAgICB9CgogICAgLy9wcmludGYoIiVzXG4iLCBhcnJheVtjb250LTFdKTsKICAgIC8vcHJpbnRmKCIlc1xuIiwgYXJyYXlbY29udC0yXSk7CiAgICAvL3ByaW50ZigiJXNcbiIsIGFycmF5W2NvbnQtM10pOwoKICA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