Read text file and store fields in variables

Asked

Viewed 125 times

0

I need help on the following: I will do a b-tree to present a work at the college, which consists of reading the data from a text file and passing them to the B Tree. I will do as follows: I created a struct with the data types (Lot; Board; UF; Motor; Renavam; Chassis; Year; Brand/ Model; Owner; Financial; Value) and I will store the Lot in B-Tree and then when they search for the lot, I will display the struct data related to the lot. The question now is how to read the text file as I am not able to read and store the information in their respective variables.

Follows as the file is:

Lote; Placa; UF; Motor; Renavam; Chassi; Ano; Marca/ Modelo; Proprietário; Financeira; Valor
0001; LJG6509; DF; BA042893; 00300896778; 7SK182224; 1974; VW/BRASILIA; GONCALO JOSE DE FRANCA; MARCAL DE ASSIS BRASIL; 3000.00
0002; HBR7108; DF; 9BD17206G83400203; 00954371330; 178F1011*8002263*; 2008; FIAT/SIENA FIRE FLEX; ANTONIO AUGUSTO ALVES DOS SANTOS; AYMORE FINANCIAMENTOS;3450.00
0003; JJB0059; DF; 9BD17201B53124230; 00838026320; 178E9011*6128825*; 2004; FIAT/SIENA ELX FLEX; JOAO ALBERTO SANTOS SOBRINHO; BANCO BRADESCO FINANCIAMENTOS S.A. ; 3450.00
0004; JGG0484; DF; 93HGD17404Z120657; 00824912748; L13A4-H113508; 2004; HONDA/FIT LX; FERNANDO EVARISTO DOS SANTOS; BANCO FINASA SA; 3030.00
0005; LJQ8142; RJ; LB8ABK60592; 00304920886; SUPRIMIDO; 1983; FORD/DEL REY; JOSE SIQUEIRA; AYMORE LEASING; 3150.00
0006; JDQ0675; DF; 9BG5TC11UFC158987; 00293715343; 5JH20PA48199; 1985; GM/CHEVETTE; RODRIGO DE CASTRO PAULA; AYMORE FINANCIAMENTOS; 3530.00
0007; JGQ8447; DF; 9BFZF10B678103244; 00889829691; CAJA78103244; 2006; FORD/FIESTA; ANDREA CRISTINA CHAVES MACHADO; BANCO ITAUCARD SA; 3100.00
0008; JDS8539; GO; BA170068; 00001269992; SUPRIMIDO; 1975; VW/BRASILIA; SAMUEL SOARES SARAFIM; BV FINANCEIRA SA CFI; 2850.00
0009; JFT5423; DF; 9BGSD19401C189366; 00751983616; CJ0039685; 2000; GM/CORSA SUPER; ELOI NUNES DE SOUSA; PANAMERICANO; 3550.00
0010; JJD1340; DF; 9BD178237T0079169; 00663876648; 4777947; 1996; FIAT/PALIO EL; LEANDRO DANTAS LIMA; BANCO PANAMERICANO SA; 3450.00
0011; KDR1120; DF; 9BGLK19BRRB315479; 00627287034; C20NE31014740L; 1994; GM/VECTRA GLS; MAURICIO DE LIMA SILVA; HSBC BANK BRASIL S/A BM; 2480.00
0012; KAW6325; GO; LB4DPA78820; 00112493793; SUPRIMIDO; 1975; FORD/CORCEL; LEVINO MACHADO DA COSTA; BANCO PANAMERICANO SA; 1880.00
0013; JEQ3930; DF; BS012252; 00000121967; BH136193; 1970; VW/FUSCA 1500; SILVANA APARECIDA DA SILVA; UNIBANCO - UNIAO DE BANCOS BRASILEIROS S.A.; 1850.00
0014; HYS6690; CE; 9BGRD48X04G134684; 00818350288; 7V0009127; 2003; GM/CELTA 5 PORTAS; SIMONE QUINTINO MENDES DA VITORIA; BANCO GMAC; 3500.00
0015; JGA2435; DF; 9BGSC68Z01B167794; 00759527709; SUPRIMIDO; 2001; GM/CORSA WIND; CLEUSA DO ROSARIO A SIQUEIRA; AYMORE FINANCIAMENTOS; 3100.00
0301; JHH8778; DF; 8BCLDRFJ48G521910; 00939636573; SUPRIMIDO; 2007; I/CITROEN C4 PALLAS20GLM; CRISTIANE MONTEIRO LIMA PAIVA; CAIXA ECONÔMICA FEDERAL; 2000.00
0302; JKJ5612; DF; 9BWAA05W5DP091431; 00500162247; CCP396671; 2012; VW/GOL 1.0 ECOMOTION GIV; ANTONIO ALVES DE OLIVEIRA; BANCO PANAMERICANO SA; 2500.00
0303; JHY8370; DF; 8AGCN48X0BR142232; 00253254264; U55060355; 2010; I/CHEVROLET AGILE LTZ; N.A PIZZARIA RESTAURANTE E SERVICOS DE B; BB ADMNISTRADORA DE CONSC SA; 3500.00
0304; LNN3808; DF; 93UMA48L714010797; 00766868516; AKL734422; 2001; AUDI/A3 1.6; ALEX ANTONIO DA SILVA; BANCO BRADESCO SA; 2000.00
0305; LOM1229; DF; 9BMMF33E43A047599; 00797678336; 16696030636876; 2003; M.BENZ/A 160; JOSE BATISTA VIEIRA; BANCO BRADESCO SA; 2000.00
0306; JIS7553; DF; 8AP17206LB2201591; 00322387884; 310A10110162774; 2011; I/FIAT SIENA FIRE FLEX; JULIO CESAR GARCIA FILHO; BV FINANCEIRA SA CFI; 2500.00
0307; JIC8524; DF; 9BD135316A2122152; 00146989040; X8*0463078*; 2009; FIAT/IDEA ADVENTURE FLEX; FRANCIVALDO SOARES JACOBINA; BANCO BRADESCO FINANCIAMENTOS S.A.; 2500.00
0308; JIC0333; DF; 9BWAA05U5AP099734; 00193353180; CCN417375; 2010; VW/GOL 1.0; MARISA VIANA PEREIRA; BANCO ITAU CFI; 2000.00
0309; JJH5857; DF; LJ12FKR10C4271258; 00451856970; HFC4EB13DB3468084; 2011; I/JAC J3 TURIN; ABRAAO ALVES COSTA; BANCO PANAMERICANO SA; 2000.00
0310; JGN4857; DF; 9BD15822764731812; 00860177602; 146E1011*6513692*; 2005; FIAT/UNO MILLE FIRE FLEX; JORGE LUIZ SCHUMCHER; BANCO PANAMERICANO SA; 2000.00
0311; HAB5748; DF; 9BD17103232203526; 00785472452; 5504789; 2002; FIAT/PALIO FIRE; EDITE ROSADIAS DE SOUZA; BANCO PANAMERICANO SA; 2000.00
0312; JIV8133; DF; 93YLSR6RHBJ754270; 00325257922; D4DH760Q151276; 2011; RENAULT/LOGAN AUT 1016V; ELZI PEREIRA DA SILVA; CIA CFI RCI BRASIL; 2500.00
0313; JIB6665; DF; 9BFZK03P19B023479; 00966756134; QFRA9023479; 2008; 153308-FORD/KA 1.6FLEX; CARLEONE SILVA COSTA; BANCO PANAMERICANO SA; 2500.00
0314; CRE3624; DF; WVWGC63B9WE454295; 00715180053; ACK086808; 1998; I/VW PASSAT V6; PUMA LOCADORA E TURISMO LTDA ME; BANCO PANAMERICANO SA; 2000.00
0315; JJH2574; DF; 9BWAA05W9BP046926; 00269279202; CCP225918; 2010; VW/GOL 1.0 GIV; ELIANE NASCIMENTO DA SILVA.; BANCO ITAUCARD SA; 2000.00
0316; JHA6732; DF; 9BD17164LA5376665; 00127823654; 310A1011*8648527*; 2009; FIAT/PALIO FIRE ECONOMY; JOSE GONCALVES VIEIRA; BANCO PANAMERICANO SA; 2000.00
0317; JHF5499; DF; 9BD15822A96191255; 00986553212; 146E1011*8501060*; 2008; FIAT/UNO MILLE ECONOMY; FRANCISCO JOSE ENIO DA SILVA; BANCO FIAT S/A; 2000.00
0318; JIC5460; DF; 9BD110585A1527407; 00253104670; 310A3011*8723769*; 2010; FIAT/LINEA HLX 1.9 DUAL; ANDERSON JOSE BORGES; BV FINANCEIRA SA CFI; 2500.00
0319; JKK6367; DF; 9BFZF55A0D8486830; 00538849410; SM9AD8486830; 2013; FORD/FIESTA FLEX; ERINALDO RIBEIRO DE SOUZA; BANCO ITAUCARD SA; 2000.00
0320; DVD7522; DF; 9BWKB05Z174037965; 00898975522; BPA126696; 2006; VW/CROSSFOX; BRAS CANDIDO BORBA; BANCO PANAMERICANO SA; 2000.00
0321; DKF6896; DF; 9BWKA05Z754019406; 00834445921; BJE025796; 2004; VW/FOX 1.0; LUCILENE SILVA ALVES TEIXEIRA; REAL LEASING SA ARRENDAMENTO MERCANTIL; 2000.00
0322; JJC7064; DF; LJ12EKP12E4601216; 00534448585; HFC4EB13DD3415663; 2013; I/JAC J2 1.4; CECILIO LOPES SALES; AYMORE FINANCIAMENTOS; 2500.00
0323; HPW0298; DF; 94DCMGD225J565003; 00847531090; 40704191102; 2004; NISSAN/FRONTIER 4X2 SE; EDIMAURA PAES DE SOUSA; BANCO ITAUCARD SA; 3000.00
0325; JJJ3627; DF; LSCBB13D8CG800943; 00457564725; JL466Q4B64F019260; 2011; I/CHANGAN CHANA SC13D; FRANCINALDO MOTA; BRB CREDITO FINANCIAMENTO E INVESTIMENTO S A; 1500.00
0326; JHR0456; DF; 8AD3DRFJ47G049541; 00926565281; 10LH4P1516969; 2006; I/PEUGEOT 307SD 20S M FL; ELMO ELIAS SANTOS NASCIMENTO; AYMORE FINANCIAMENTOS; 2500.00
0327; JHL7740; DF; 9BWAA05U5AT154996; 00178301620; CCN377037; 2009; VW/GOL 1.0; CARLOS ALBERTO DA CUNHA SIMOES; AYMORE FINANCIAMENTOS; 2000.00
0328; JHF6749; DF; 9BD17206G93476865; 00986960845; 178F1011*8498738*; 2008; FIAT/SIENA FIRE FLEX; GILSON FARIAS DE ANDRADE; BB LEASING SA ARREND. MERCANTIL; 2000.00
0329; JHS9868; DF; 9BWAB05Z294059634; 00982925719; CCR036280; 2008; VW/CROSSFOX; VIVIANE FERNANDES DA SILVA; BANCO BMC S/A - FINASA; 2500.00
0330; JGS6557; DF; 93HFA16307Z108363; 00890983810; R18A1-7Z108367; 2006; HONDA/CIVIC LXS; EURANIO SOARES SANTOS; ITAU UNIBANCO S.A.; 3000.00
0331; JIO0289; DF; LVVDB12B0BD167850; 00333102118; SQR473FAFBC01664; 2011; I/CHERY FACE 1.3; WM COMERCIO E INDUSTRIA DE VIDROS LTDA; AYMORE FINANCIAMENTOS; 2000.00
0332; JKJ5719; DF; 9BD372110D4034781; 00539312398; 310A10111459900; 2013; FIAT/SIENA EL 1.0 FLEX; JURACY SILVA DE ALMEIDA; BANCO PANAMERICANO SA; 2500.00
0333; JGU6486; DF; 9BD11985461031944; 00871362902; 5M*0173519*; 2005; FIAT/DOBLO ADVENTURE; PAULO AUGUSTO DE SAO JOSE ; BANCO BRADESCO FINANCIAMENTOS S.A.; 2000.00
0334; JJK0638; DF; 4S4WXFLU5BS029612; 00459571680; U394686; 2010; I/SUBARU TRIBECA; ESPOBRAS CONSTRUCAO E INCORPORACAO LTDA; BRADESCO LEASING S.A. - ARRENDAMENTO MERCANTIL; 3500.00
0335; JKJ8367; DF; 9BD15822AD6830581; 00538014156; 146E10111480325; 2013; FIAT/UNO MILLE ECONOMY; RICARDO DOS SANTOS; BANCO PANAMERICANO SA; 2000.00
0336; JGB3807; DF; 9BD17140212078216; 00762552905; 5127709; 2001; FIAT/PALIO EX; HELIO DA SILVA COUTINHO; BANCO ITAUCARD SA; 2000.00
0337; JDV8492; DF; 9BFZF20B558295288; 00846940000; CAJA58295288; 2005; FORD/FIESTA SEDAN; JOAQUIM JUARES DA SILVA; BANCO PECUNIA S/A; 2000.00
0338; JHN0991; DF; 8BCLDRFJWAG528812; 00199523363; 10TWAA0037624; 2009; I/CITROEN C4 PALLAS20EAF; PAULO HENRIQUE CARVALHO DE MELO ME; CAIXA ECONÔMICA FEDERAL; 3000.00
0339; JGZ5695; DF; 9BWCA05W66T164423; 00885894626; BNW097198; 2006; VW/GOL 1.0; PATRICIA DE JESUS OLIVEIRA; BANCO PANAMERICANO SA; 1500.00
0340; JHN2980; DF; 9BWDB09N5AP014145; 00172998115; BPA214436; 2009; VW/POLO SEDAN 1.6; VALDEIR ALVES NOGUEIRA; BANCO ITAUCARD SA; 2000.00
0341; JHM0175; DF; 9BD17206G73324431; 00919759297; 178F1011*7552450*; 2007; FIAT/SIENA FIRE FLEX; ELAINE MARIA FERREIRA LIRA; BANCO PANAMERICANO SA; 2000.00
0342; JIK9533; DF; 9BWAA05U9BT161869; 00259555479; CCN661628; 2010; VW/GOL 1.0; MARIA DOS REIS DAMASCENO DA CRUZ; BV FINANCEIRA SA CFI; 2000.00
0343; JIS7029; DF; 9BD15802AC6641487; 00363467912; 146E10110537174; 2011; FIAT/UNO MILLE ECONOMY; CLERISTON APOLINARIO DE ALCANTARA; BANCO FIAT S/A; 2000.00
0344; JHZ8910; DF; 9BGRM69X0BG201219; 00256126208; NAC034829; 2010; GM/PRISMA MAXX; TEMISTOCLES FERREIRA MENEZES; BV LEASING ARRENDAMENTO MERCANTIL SA; 2000.00
0345; HCU7682; DF; 8AD3CRFN16G012508; 00889092001; 10LH2X1388201; 2005; I/PEUGEOT 307 20 FELINE; ADRIANA DOMINGOS DE OLIVEIRA; BANCO PANAMERICANO SA; 2000.00
0347; JHB2412; DF; 9BGSA19109B248600; 00128377208; S80006976; 2009; GM/CLASSIC LIFE; SEBASTIAO JORGE DOS SANTOS; BFB LEASING S.A. ARRENDAMENTO MERCANTIL; 2500.00
0349; JHL9804; DF; 9BWGF07X18P023201; 00959668322; BTJ052200; 2008; VW/KOMBI; VAGNER BARBOSA DAMASCENO; SOROCRED - CREDITO, FINANC. E INVESTIMENTO S/A; 2500.00
0350; JIF4985; DF; 9BD17164G85232345; 00967203520; 178F1011*8169351*; 2008; FIAT/PALIO FIRE FLEX; MARCIEL MENDES DOS SANTOS; CAIXA ECONÔMICA FEDERAL; 2500.00
0351; JGU7099; DF; 9BWCA05W46T197050; 00894987666; BNW124850; 2006; VW/GOL 1.0 COPA; LEONARDO FERRAZ DE QUEIROZ; BANCO ITAUCARD SA; 2000.00
0352; JIB9378; DF; 9BFZF54A798415312; 00164380370; SM9A98415312; 2009; FORD/FIESTA SEDAN FLEX; FLORA MECUPRE COELHO DA MOTA CABRAL; BANCO PANAMERICANO SA; 2000.00
0353; JHB6982; DF; 9BD19250R93087919; 00126902100; Q7*0414787*; 2009; FIAT/STILO SPORTING FLEX; WESLEY HOLANDA DA SILVA; AYMORE FINANCIAMENTOS; 2000.00
0354; JHS1582; DF; 9BWAA05U3AT230876; 00200075160; CCN462504; 2010; VW/GOL 1.0; FABIANO SILVA DOS SANTOS; BANCO BRADESCO FINANCIAMENTOS S.A.; 2500.00
0356; JKE9912; DF; 9BWAB05U0DT078699; 00469748125; CCRN38259; 2012; VW/GOL 1.6; PONTO COM SOLUCOES EM TEC DA INF LTDA ME; BANCO SANTANDER BRASIL S/A; 2500.00
0357; JEM7016; DF; 9BWKA05Z544018334; 00828846650; BJE012286; 2004; VW/FOX 1.0; JOSEANNE MARIA DA SILVA LUZIA; HSBC BANK BRASIL S/A BM; 2000.00
0358; JFU9161; DF; 9362AN6A96B016806; 00873961633; 10DBTX0000451; 2005; PEUGEOT/206 16 HOLID FX; CLEY FERREIRA DE MACEDO; BB LEASING SA ARREND. MERCANTIL; 2000.00
0359; JHO8032; DF; 9BFZF54P4A8034381; 00198371420; QF9AA8034381; 2010; FORD/FIESTA SEDAN1.6FLEX; MARTA APARECIDA RODRIGUES RIBEIRO; BANCO ITAU BBA SA; 2500.00
0360; JIK3300; DF; 8AP372111C6010504; 00341484245; 310A20110222639; 2011; I/FIAT SIENA EL FLEX; SERGIO BARBOSA DANTAS; BV FINANCEIRA SA CFI; 2000.00
0362; JHC2944; DF; 93HGD17607Z203068; 00919454690; L13A4-7Z203064; 2007; HONDA/FIT LXL; LUIS FELIPE DA COSTA SILVA; BANCO PANAMERICANO SA; 3500.00
0363; HAN9315; DF; 9BD19240T53030666; 00838707220; 7Z*0092586*; 2004; FIAT/STILO; MARCELO BARRAMACHER TOCANTINS; BANCO PANAMERICANO SA; 2000.00
0364; JHI3665; DF; 9BD17106G72863905; 00900855312; 178F1011*7280491*; 2006; FIAT/PALIO FIRE FLEX; ILDEMAR DA COSTA; BANCO PANAMERICANO SA; 1500.00
0365; JIB7544; DF; 9BWAA05Z494144655; 00148089003; CCN151413; 2009; VW/FOX 1.0; ADEILDE DE SOUZA CHAVES; BANCO BRADESCO FINANCIAMENTOS S.A.; 2500.00
0366; JKN0585; DF; 9BFZF55A4E8041900; 00569311802; SM9AE8041900; 2013; FORD/FIESTA FLEX; FERNANDO DOS SANTOS; BANCO PANAMERICANO SA; 2000.00
0367; KGZ8961; DF; 9BFZF55P9A8027280; 00197091482; QF9AA8027280; 2010; FORD/FIESTA 1.6 FLEX; MANOEL DOS REIS VIANA DE SOUSA; BANCO SANTANDER BRASIL S/A; 2000.00
0368; JHZ6417; DF; 9BD17164LA5464946; 00154185191; 310A1011*8923435*; 2009; FIAT/PALIO FIRE ECONOMY; AHISTIR MARA SILVA; BV FINANCEIRA SA CFI; 2000.00
0369; JHY3246; DF; 9BWCA05W38T142835; 00945920482; BNW380552; 2007; VW/GOL 1.0; JONATHAN BARBOSA SILVA; BV FINANCEIRA SA CFI; 3000.00
0370; JGR0169; DF; 8AFDZZFHA4J327237; 00813798485; 4J327237; 2003; I/FORD FOCUS 1.6L HA;NICHOLLAS MARQUES DE QUEIROZ GONÇALVES; BANCO ITAUCARD SA; 1500.00
0371; JHX2575; DF; 9BWCA05W28P074052; 00943512786; BNW362784; 2007; VW/GOL 1.0; GERSON DA SILVA FERREIRA; BANCO PANAMERICANO SA; 3000.00
  • Do NOT use images; if you want help, help us.

  • It’s just that when I put the text from the.txt file here, it became deformed.

  • So try Ctrl K.

  • Pardon... how so ?

  • Ctrl K when editing the question...

  • I just edited...

  • Welcome to the Stackoverflow in Portuguese. Do the [tour] to learn how the community, also visit [help] to make good use of the site.

  • Thank you. I’m still waiting for help ;)

Show 3 more comments

1 answer

1

Assuming your data structure is something like:

struct veiculo_s
{
    char * lote;
    char * placa;
    char * uf;
    char * renavam;
    char * chassi;
    char * motor;
    char * ano;
    char * marca_modelo;
    char * proprietario;
    char * financeira;
    char * valor;
};

Here is a (tested) solution illustrating how to load the structure data from the records of a file .CSV:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define LINHA_MAX_TAM            (1024 * 2)   /* 2 KBytes */

struct veiculo_s
{
    char * lote;
    char * placa;
    char * uf;
    char * renavam;
    char * chassi;
    char * motor;
    char * ano;
    char * marca_modelo;
    char * proprietario;
    char * financeira;
    char * valor;
};


typedef struct veiculo_s veiculo_t;


char ** strsplit( const char * src, const char * delim )
{
    char * pbuf = NULL;
    char * ptok = NULL;
    int count = 0;
    int srclen = 0;
    char ** pparr = NULL;

    srclen = strlen( src );

    pbuf = (char*) malloc( srclen + 1 );

    if( !pbuf )
        return NULL;

    strcpy( pbuf, src );

    ptok = strtok( pbuf, delim );

    while( ptok )
    {
        pparr = (char**) realloc( pparr, (count+1) * sizeof(char*) );
        *(pparr + count) = strdup(ptok);

        count++;
        ptok = strtok( NULL, delim );
    }

    pparr = (char**) realloc( pparr, (count+1) * sizeof(char*) );
    *(pparr + count) = NULL;

    free(pbuf);

    return pparr;
}


void strsplitfree( char ** strlist )
{
    int i = 0;

    while( strlist[i])
        free( strlist[i++] );

    free( strlist );
}


veiculo_t * parse_veiculo( char * linha )
{
    char ** pp = NULL;
    veiculo_t * v = NULL;

    pp = strsplit( linha, ";" );

    v = (veiculo_t*) calloc( 1, sizeof(veiculo_t) );

    v->lote = strdup(pp[0]);
    v->placa = strdup(pp[1]);
    v->uf = strdup(pp[2]);
    v->renavam = strdup(pp[3]);
    v->chassi = strdup(pp[4]);
    v->motor = strdup(pp[5]);
    v->ano = strdup(pp[6]);
    v->marca_modelo = strdup(pp[7]);
    v->proprietario = strdup(pp[8]);
    v->financeira = strdup(pp[9]);
    v->valor = strdup(pp[10]);

    strsplitfree( pp );

    return v;
}


void destroy_veiculo( veiculo_t * v )
{
    free(v->lote);
    free(v->placa);
    free(v->uf);
    free(v->renavam);
    free(v->chassi);
    free(v->motor);
    free(v->ano);
    free(v->marca_modelo);
    free(v->proprietario);
    free(v->financeira);
    free(v->valor);

    free(v);
}


void show_veiculo( veiculo_t * v )
{
    printf( "[ VEICULO ]\n" );
    printf( "   Lote: %s\n", v->lote );
    printf( "   Placa: %s\n", v->placa );
    printf( "   UF: %s\n", v->uf );
    printf( "   Motor: %s\n", v->motor );
    printf( "   RENAVAM: %s\n", v->renavam );
    printf( "   Chassi: %s\n", v->chassi );
    printf( "   Ano: %s\n", v->ano );
    printf( "   Marca/Modelo: %s\n", v->marca_modelo );
    printf( "   Proprietario: %s\n", v->proprietario );
    printf( "   Financeira: %s\n", v->financeira );
    printf( "   Valor: %s\n", v->valor );
    printf( "\n" );
}


int main( int argc, char * argv[] )
{
    char linha[ LINHA_MAX_TAM + 1 ];
    veiculo_t * v = NULL;
    FILE * fp = NULL;

    fp = fopen( argv[1], "r" );

    while( fgets( linha, LINHA_MAX_TAM, fp ) )
    {
        v = parse_veiculo( linha );
        show_veiculo( v );
        destroy_veiculo( v );
    }

    fclose(fp);

    return 0;
}

Test file:

0367; KGZ8961; DF; 9BFZF55P9A8027280; 00197091482; QF9AA8027280; 2010; FORD/FIESTA 1.6 FLEX; MANOEL DOS REIS VIANA DE SOUSA; BANCO SANTANDER BRASIL S/A; 2000.00
0368; JHZ6417; DF; 9BD17164LA5464946; 00154185191; 310A1011*8923435*; 2009; FIAT/PALIO FIRE ECONOMY; AHISTIR MARA SILVA; BV FINANCEIRA SA CFI; 2000.00
0369; JHY3246; DF; 9BWCA05W38T142835; 00945920482; BNW380552; 2007; VW/GOL 1.0; JONATHAN BARBOSA SILVA; BV FINANCEIRA SA CFI; 3000.00
0370; JGR0169; DF; 8AFDZZFHA4J327237; 00813798485; 4J327237; 2003; I/FORD FOCUS 1.6L HA;NICHOLLAS MARQUES DE QUEIROZ GONÇALVES; BANCO ITAUCARD SA; 1500.00
0371; JHX2575; DF; 9BWCA05W28P074052; 00943512786; BNW362784; 2007; VW/GOL 1.0; GERSON DA SILVA FERREIRA; BANCO PANAMERICANO SA; 3000.00

Exit:

[ VEICULO ]
   Lote: 0367
   Placa:  KGZ8961
   UF:  DF
   Motor:  QF9AA8027280
   RENAVAM:  9BFZF55P9A8027280
   Chassi:  00197091482
   Ano:  2010
   Marca/Modelo:  FORD/FIESTA 1.6 FLEX
   Proprietario:  MANOEL DOS REIS VIANA DE SOUSA
   Financeira:  BANCO SANTANDER BRASIL S/A
   Valor:  2000.00


[ VEICULO ]
   Lote: 0368
   Placa:  JHZ6417
   UF:  DF
   Motor:  310A1011*8923435*
   RENAVAM:  9BD17164LA5464946
   Chassi:  00154185191
   Ano:  2009
   Marca/Modelo:  FIAT/PALIO FIRE ECONOMY
   Proprietario:  AHISTIR MARA SILVA
   Financeira:  BV FINANCEIRA SA CFI
   Valor:  2000.00


[ VEICULO ]
   Lote: 0369
   Placa:  JHY3246
   UF:  DF
   Motor:  BNW380552
   RENAVAM:  9BWCA05W38T142835
   Chassi:  00945920482
   Ano:  2007
   Marca/Modelo:  VW/GOL 1.0
   Proprietario:  JONATHAN BARBOSA SILVA
   Financeira:  BV FINANCEIRA SA CFI
   Valor:  3000.00


[ VEICULO ]
   Lote: 0370
   Placa:  JGR0169
   UF:  DF
   Motor:  4J327237
   RENAVAM:  8AFDZZFHA4J327237
   Chassi:  00813798485
   Ano:  2003
   Marca/Modelo:  I/FORD FOCUS 1.6L HA
   Proprietario: NICHOLLAS MARQUES DE QUEIROZ GONÇALVES
   Financeira:  BANCO ITAUCARD SA
   Valor:  1500.00


[ VEICULO ]
   Lote: 0371
   Placa:  JHX2575
   UF:  DF
   Motor:  BNW362784
   RENAVAM:  9BWCA05W28P074052
   Chassi:  00943512786
   Ano:  2007
   Marca/Modelo:  VW/GOL 1.0
   Proprietario:  GERSON DA SILVA FERREIRA
   Financeira:  BANCO PANAMERICANO SA
   Valor:  3000.00
  • In the strsplit function, in the pparr chunk = (char**) realloc( pparr, (Count+1) * sizeof(char*) ). The ppar pointer causes the string vector to grow continuously in runtime ?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.