//pointer memory use instead of structure stack memory

//pointer memory use instead of structure stack memory

//pointer memory use instead of structure stack memory

//pointer memory use instead of structure stack memory

 

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

 

#define MAX_ADDRESS_CNT 200

 

struct st_basic_trade

{

    char dataclass[2];

    char infoclass[2];

    char marketclass[1];

    char stockcode[12];

    char serialno[8];

    char abbrstockcode[9];

    char abbrstocknamekor[40];

    char abbrstocknameeng[40];

    char senddate[8];

    char infodivisiongroupno[5];

    char stockgroupid[2];

    char isunittrade[1];

    char exclasscode[2];

    char facevaluechangeclasscode[2];

    char isopenpricebasedstandardprice[1];

    char isrevaluationstockreason[2];

    char isstandardpricechangestock[1];

    char israndomendpossibillty[1];

    char ismarketalarmdangernotice[1];

    char marketalarmclasscode[2];

    char iscorporategovernancefine[1];

    char ismanagementstock[1];

    char isinsinceritypublicnewsappoint[1];

    char isbackdoorlisting[1];

    char istradestop[1];

    char indexbusinesstypelarge[3];

    char indexbusinesstypemedium[3];

    char indexbusinesstypesmall[3];

    char standardindustrycode[10];

    char businesstypekospi200[1];

    char listpricesizecode[1];

    char ismanufactureindustry[1];

    char iskrx100stock[1];

    char isdividendindexstock[1];

    char iscorporategovernanceindexstock[1];

    char investorganclasscode[2];

    char iskospi[1];

    char iskospi100[1];

    char iskospi50[1];

    char iskrxsectorindexcar[1];

    char iskrxsectorindexsemiconductor[1];

    char iskrxsectorindexbio[1];

    char iskrxsectorindexfinance[1];

    char iskrxsectorindexit[1];

    char iskrxsectorindexenergychemical[1];

    char iskrxsectorindexsteel[1];

    char iskrxsectorindexnecessary[1];

    char iskrxsectorindexmediacomm[1];

    char iskrxsectorindexconstruction[1];

    char iskrxsectorindexfinanceservice[1];

    char iskrxsectorindexstock[1];

    char iskrxsectorindexship[1];

    char standardprice[9];

    char ydayclosepriceclasscode[1];

    char ydaycloseprice[9];

    char ydayaccmvolume[12];

    char ydayaccmamount[18];

    char uplimitprice[9];

    char downlimitprice[9];

    char substituteprice[9];

    char facevalue[12];

};

 

int main(int argc, char *argv[])

{

    struct st_basic_trade st_basic_trade[MAX_ADDRESS_CNT];

 

struct st_basic_trade *address_byte_trade1;

struct st_basic_trade *address_byte_trade2;

struct st_basic_trade *address_byte_trade_tmp;

 

char *address_byte[MAX_ADDRESS_CNT];//st_basic_trade structure address saving pointer array

char *address_byte_tmp;//st_basic_trade structure address saving pointer

 

    FILE *fp=NULL;//file pointer

char rbuf[4096];//file read buffer

 

char tmp1[200];

char tmp2[200];

int ii,kk,continue_tmp;

int st_basic_trade_cnt;

 

if((fp=fopen("BATCH_A0011.dat", "rt"))==NULL)

{

return(-1);

}

 

    //DATA MEMORY INIT

//DATA MEMORY INIT

for(kk=0; kk<MAX_ADDRESS_CNT; kk++)

{

memset(&st_basic_trade[kk],0x00,sizeof(st_basic_trade[kk]));

}

 

    //DATA LOAD FROM FILE

//DATA LOAD FROM FILE

    kk=0;

while(1)

{

memset(rbuf,0x00,sizeof(rbuf));

if(fgets(rbuf,sizeof(rbuf),fp)==NULL) break;

 

memcpy(&st_basic_trade[kk], rbuf, (int)sizeof(st_basic_trade[kk]));

 

continue_tmp=-1;

 

if(memcmp(st_basic_trade[kk].stockgroupid,"ST",2)==0) continue_tmp=100;

        if(memcmp(st_basic_trade[kk].stockgroupid,"EF",2)==0) continue_tmp=100;

        if(memcmp(st_basic_trade[kk].stockgroupid,"RT",2)==0) continue_tmp=100;

        if(memcmp(st_basic_trade[kk].stockgroupid,"MF",2)==0) continue_tmp=100;

        if(memcmp(st_basic_trade[kk].stockgroupid,"SC",2)==0) continue_tmp=100;

        if(memcmp(st_basic_trade[kk].stockgroupid,"IF",2)==0) continue_tmp=100;

        if(memcmp(st_basic_trade[kk].stockgroupid,"DR",2)==0) continue_tmp=100;

        if(memcmp(st_basic_trade[kk].stockgroupid,"FS",2)==0) continue_tmp=100;

     if(memcmp(st_basic_trade[kk].stockgroupid,"EN",2)==0) continue_tmp=100;

 

if(continue_tmp<0) continue;

kk++;

 

if(kk==MAX_ADDRESS_CNT) break;

}

st_basic_trade_cnt=kk;

if(fp != NULL) fclose(fp);

 

//POINTER MEMORY USE INSTEAD OF STRUCTURE STACK MEMORY

//POINTER MEMORY USE INSTEAD OF STRUCTURE STACK MEMORY

for(kk=0; kk<st_basic_trade_cnt; kk++)

{

address_byte[kk] = (char *)&st_basic_trade[kk];

}

 

    //DESCENDING BY POINTER MEMORY

//DESCENDING BY POINTER MEMORY

for(kk=0; kk<st_basic_trade_cnt; kk++)

{

for(ii=kk+1; ii<st_basic_trade_cnt; ii++)

{

address_byte_trade1 = (struct st_basic_trade *)address_byte[kk];

address_byte_trade2 = (struct st_basic_trade *)address_byte[ii];

 

memset(tmp1,0x00,sizeof(tmp1));

memset(tmp2,0x00,sizeof(tmp2));

 

sprintf(tmp1, "%.*s", (int)sizeof(address_byte_trade1->standardprice), address_byte_trade1->standardprice);

sprintf(tmp2, "%.*s", (int)sizeof(address_byte_trade2->standardprice), address_byte_trade2->standardprice);

 

if(atoi(tmp1) > atoi(tmp2))

{

address_byte_tmp=address_byte[kk];

address_byte[kk]=address_byte[ii];

address_byte[ii]=address_byte_tmp;

}

}

}

 

//RESULT DISPLAY

//RESULT DISPLAY

for(kk=0; kk<st_basic_trade_cnt; kk++)

{

address_byte_trade_tmp = (struct st_basic_trade *)address_byte[kk];

 

printf(

    "[%.4d]:"

    "(%.*s)"

    "(%.*s)"

    "(%.*s)"

    "(%.*s)"

    "(%.*s)"

    "(%.*s)"

    "(%.*s)"

    "(%.*s)"

    "(%.*s)"

    "(%.*s)"

    "(%.*s)"

    "(%.*s)"

    "\n"

kk+1,

(int)sizeof(address_byte_trade_tmp->iskospi),address_byte_trade_tmp->iskospi,

(int)sizeof(address_byte_trade_tmp->dataclass),address_byte_trade_tmp->dataclass,

(int)sizeof(address_byte_trade_tmp->infoclass),address_byte_trade_tmp->infoclass,

(int)sizeof(address_byte_trade_tmp->serialno),address_byte_trade_tmp->serialno,

(int)sizeof(address_byte_trade_tmp->stockgroupid),address_byte_trade_tmp->stockgroupid,

(int)sizeof(address_byte_trade_tmp->abbrstockcode),address_byte_trade_tmp->abbrstockcode,

(int)sizeof(address_byte_trade_tmp->standardprice),address_byte_trade_tmp->standardprice,

(int)sizeof(address_byte_trade_tmp->ydayaccmvolume),address_byte_trade_tmp->ydayaccmvolume,

(int)sizeof(address_byte_trade_tmp->ydayaccmamount),address_byte_trade_tmp->ydayaccmamount,

(int)sizeof(address_byte_trade_tmp->uplimitprice),address_byte_trade_tmp->uplimitprice,

(int)sizeof(address_byte_trade_tmp->downlimitprice),address_byte_trade_tmp->downlimitprice,

(int)sizeof(address_byte_trade_tmp->abbrstocknameeng),address_byte_trade_tmp->abbrstocknameeng);

}

return(0);

}

 

/*RESULT

[0140]:(Y)(A0)(01)(00000068)(ST)(A000860  )(000035500)(000000012109)(000000000427932950)(000046150)(000024850)(KANGNAM JEVISCO                         )

[0141]:(Y)(A0)(01)(00000069)(ST)(A000880  )(000035550)(000000250112)(000000008841239150)(000046200)(000024900)(Hanwha                                  )

[0142]:(Y)(A0)(01)(00000161)(ST)(A002390  )(000035800)(000000175128)(000000006200375550)(000046500)(000025100)(HANDOK                                  )

[0143]:(Y)(A0)(01)(00000062)(ST)(A000720  )(000036000)(000000935395)(000000033665525250)(000046800)(000025200)(HyundaiEng&Const                        )

[0144]:(Y)(A0)(01)(00000168)(ST)(A002620  )(000037150)(000000043866)(000000001645729300)(000048250)(000026050)(JeilPharm                               )

[0145]:(Y)(A0)(01)(00000031)(ST)(A000180  )(000038150)(000000051172)(000000001962002000)(000049550)(000026750)(SCEHoldings                             )

[0146]:(Y)(A0)(01)(00000080)(ST)(A001060  )(000040300)(000000157559)(000000006374627600)(000052300)(000028250)(JWPHARMA                                )

[0147]:(Y)(A0)(01)(00000082)(ST)(A001067  )(000042550)(000000000536)(000000000022519300)(000055300)(000029800)(JWPHARMA(2PB)                           )

[0148]:(Y)(A0)(01)(00000063)(ST)(A000725  )(000043150)(000000000564)(000000000024648550)(000056000)(000030250)(HyundaiEng&Con(1P)                      )

[0149]:(Y)(A0)(01)(00000039)(ST)(A000270  )(000043550)(000001342543)(000000058170323500)(000056600)(000030500)(KiaMtr                                  )

[0150]:(Y)(A0)(01)(00000147)(ST)(A002170  )(000044500)(000000010952)(000000000488631300)(000057800)(000031150)(SamyangTongsang                         )

[0151]:(Y)(A0)(01)(00000163)(ST)(A002420  )(000045400)(000000001276)(000000000057439100)(000059000)(000031800)(Century                                 )

[0152]:(Y)(A0)(01)(00000126)(ST)(A001745  )(000045750)(000000001253)(000000000058412550)(000059400)(000032050)(SKNetworks(1P)                          )

[0153]:(Y)(A0)(01)(00000124)(ST)(A001725  )(000046950)(000000000551)(000000000025664750)(000061000)(000032900)(ShinyoungSecu(1P)                       )

[0154]:(Y)(A0)(01)(00000123)(ST)(A001720  )(000049550)(000000002054)(000000000101791900)(000064400)(000034700)(ShinyoungSecu                           )

[0155]:(Y)(A0)(01)(00000030)(ST)(A000157  )(000050500)(000000000118)(000000000005902400)(000065600)(000035400)(DOOSAN(2PB)                             )

[0156]:(Y)(A0)(01)(00000067)(ST)(A000850  )(000050800)(000000001558)(000000000079929400)(000066000)(000035600)(HMT                                     )

[0157]:(Y)(A0)(01)(00000029)(ST)(A000155  )(000051000)(000000001053)(000000000053774400)(000066300)(000035700)(DOOSAN(1P)                              )

[0158]:(Y)(A0)(01)(00000192)(ST)(A003030  )(000051800)(000000009657)(000000000494291400)(000067300)(000036300)(SeAhStl                                 )

[0159]:(Y)(A0)(01)(00000073)(ST)(A000950  )(000053000)(000000001352)(000000000072137200)(000068900)(000037100)(Chonbang                                )

[0160]:(Y)(A0)(01)(00000156)(ST)(A002320  )(000053200)(000000053672)(000000002833688300)(000069100)(000037300)(HanjinTrnspt                            )

[0161]:(Y)(A0)(01)(00000196)(ST)(A003080  )(000055200)(000000000851)(000000000046476300)(000071700)(000038700)(SungboChem                              )

[0162]:(Y)(A0)(01)(00000083)(ST)(A001070  )(000056400)(000000001586)(000000000088415000)(000073300)(000039500)(TaihanTextl                             )

[0163]:(Y)(A0)(01)(00000137)(ST)(A001940  )(000058300)(000000002805)(000000000163564100)(000075700)(000040900)(KISCO Holdings                          )

[0164]:(Y)(A0)(01)(00000114)(ST)(A001530  )(000059200)(000000001443)(000000000085351600)(000076900)(000041500)(Dongil                                  )

[0165]:(Y)(A0)(01)(00000197)(ST)(A003090  )(000063200)(000000007172)(000000000457728500)(000082100)(000044300)(Daewoong                                )

[0166]:(Y)(A0)(01)(00000057)(ST)(A000650  )(000063600)(000000000824)(000000000053056100)(000082600)(000044600)(ChunilExp                               )

[0167]:(Y)(A0)(01)(00000140)(ST)(A002020  )(000070600)(000000044170)(000000003133398600)(000091700)(000049500)(KOLON CORP                              )

[0168]:(Y)(A0)(01)(00000028)(ST)(A000150  )(000072400)(000000117697)(000000008567840400)(000094100)(000050700)(DOOSAN                                  )

[0169]:(Y)(A0)(01)(00000055)(ST)(A000590  )(000072600)(000000001684)(000000000122223400)(000094300)(000050900)(CSHOLDINGS                              )

[0170]:(Y)(A0)(01)(00000032)(ST)(A000210  )(000077600)(000000148934)(000000011570941400)(000100500)(000054400)(DaelimInd                               )

[0171]:(Y)(A0)(01)(00000020)(ST)(A000075  )(000077800)(000000000177)(000000000013515400)(000101000)(000054500)(SAMYANGHOLDINGS(1P)                     )

[0172]:(Y)(A0)(01)(00000048)(ST)(A000480  )(000080600)(000000000412)(000000000033291100)(000104500)(000056500)(ChosunRefrctr                           )

[0173]:(Y)(A0)(01)(00000179)(ST)(A002795  )(000087500)(000000052984)(000000004654231400)(000113500)(000061300)(AmoreG(1P)                              )

[0174]:(Y)(A0)(01)(00000205)(ST)(A003300  )(000094800)(000000020468)(000000001954590400)(000123000)(000066400)(HanilCement                             )

[0175]:(Y)(A0)(01)(00000142)(ST)(A002030  )(000098300)(000000000761)(000000000074790600)(000127500)(000068900)(ASIA HOLDINGS                           )

[0176]:(Y)(A0)(01)(00000198)(ST)(A003120  )(000107500)(000000000483)(000000000051978500)(000139500)(000075500)(IlsungPharm                             )

[0177]:(Y)(A0)(01)(00000119)(ST)(A001630  )(000120000)(000000020708)(000000002442273500)(000156000)(000084000)(CHONGKUNDANG HOLDINGS                   )

[0178]:(Y)(A0)(01)(00000079)(ST)(A001045  )(000135000)(000000002881)(000000000387653500)(000175500)(000094500)(CJ(1P)                                  )

[0179]:(Y)(A0)(01)(00000200)(ST)(A003200  )(000148000)(000000001833)(000000000268996500)(000192000)(000104000)(IlshinSpng                              )

[0180]:(Y)(A0)(01)(00000178)(ST)(A002790  )(000161000)(000000715462)(000000113395522000)(000209000)(000113000)(AmoreG                                  )

[0181]:(Y)(A0)(01)(00000167)(ST)(A002600  )(000161000)(000000000169)(000000000027542500)(000209000)(000113000)(CHOHEUNG                                )

[0182]:(Y)(A0)(01)(00000019)(ST)(A000070  )(000177000)(000000028579)(000000005043584000)(000230000)(000124000)(SAMYANGHOLDINGS                         )

[0183]:(Y)(A0)(01)(00000182)(ST)(A002840  )(000179000)(000000000063)(000000000011328500)(000232500)(000125500)(MiwonComcl                              )

[0184]:(Y)(A0)(01)(00000086)(ST)(A001130  )(000184000)(000000000647)(000000000119095000)(000239000)(000129000)(DaehanFlrMill                           )

[0185]:(Y)(A0)(01)(00000024)(ST)(A000105  )(000190000)(000000000029)(000000000005484500)(000247000)(000133000)(Yuhan(1P)                               )

[0186]:(Y)(A0)(01)(00000066)(ST)(A000815  )(000195000)(000000003175)(000000000613795000)(000253500)(000136500)(SamsungF&MIns(1P)                       )

[0187]:(Y)(A0)(01)(00000105)(ST)(A001465  )(000198500)(000000000076)(000000000015081500)(000258000)(000139000)(BYC(1P)                                 )

[0188]:(Y)(A0)(01)(00000017)(ST)(A000050  )(000203000)(000000001581)(000000000318739000)(000263500)(000142500)(Kyungbang                               )

[0189]:(Y)(A0)(01)(00000056)(ST)(A000640  )(000214000)(000000013643)(000000002898145500)(000278000)(000150000)(Donga Socio Holdings                    )

[0190]:(Y)(A0)(01)(00000025)(ST)(A000120  )(000216000)(000000029404)(000000006392050500)(000280500)(000151500)(CJ korea express                        )

[0191]:(Y)(A0)(01)(00000078)(ST)(A001040  )(000281500)(000000039434)(000000011175365500)(000365500)(000197500)(CJ                                      )

[0192]:(Y)(A0)(01)(00000065)(ST)(A000810  )(000303500)(000000038064)(000000011500917820)(000394500)(000212500)(SamsungF&MIns                           )

[0193]:(Y)(A0)(01)(00000023)(ST)(A000100  )(000330000)(000000030710)(000000010129506500)(000429000)(000231000)(Yuhan                                   )

[0194]:(Y)(A0)(01)(00000160)(ST)(A002380  )(000432000)(000000014528)(000000006278496500)(000561000)(000302500)(KCC                                     )

[0195]:(Y)(A0)(01)(00000187)(ST)(A002960  )(000485000)(000000000772)(000000000378426000)(000630000)(000339500)(HankookShellOil                         )

[0196]:(Y)(A0)(01)(00000104)(ST)(A001460  )(000532000)(000000000326)(000000000172720000)(000691000)(000373000)(BYC                                     )

[0197]:(Y)(A0)(01)(00000059)(ST)(A000670  )(000931000)(000000001930)(000000001790511000)(001210000)(000652000)(Youngpoong                              )

[0198]:(Y)(A0)(01)(00000153)(ST)(A002270  )(000943000)(000000003189)(000000002984664000)(001225000)(000661000)(LotteFood                               )

[0199]:(Y)(A0)(01)(00000203)(ST)(A003240  )(000986000)(000000000664)(000000000656189000)(001281000)(000691000)(TaekwangInd                             )

[0200]:(Y)(A0)(01)(00000134)(ST)(A001800  )(001028000)(000000010402)(000000010702212000)(001336000)(000720000)(ORION                                   )

bash-3.1$

*/

+ Recent posts