//구조체에 맞는 파일을 읽어들여서 해당변수로 정렬하는 프로그램(정렬시에 스택변수사용시)
//구조체에 맞는 파일을 읽어들여서 해당변수로 정렬하는 프로그램(정렬시에 스택변수사용시)
//구조체에 맞는 파일을 읽어들여서 해당변수로 정렬하는 프로그램(정렬시에 스택변수사용시)
//구조체에 맞는 파일을 읽어들여서 해당변수로 정렬하는 프로그램(정렬시에 스택변수사용시)
//CALL BY VALUE & CALL BY REFERENCE
//CALL BY VALUE & CALL BY REFERENCE
//CALL BY VALUE & CALL BY REFERENCE
//CALL BY VALUE & CALL BY REFERENCE
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct KSEMASTBATCH {
char dataclass[2];
char infoclass[2];
char marketclass;
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;
char exclasscode[2];
char ff;
};
#define SZ_KSEMASTBATCH sizeof(struct KSEMASTBATCH)
int main(int argc, char *argv[])
{
FILE *fp=NULL;
char rbuf[4096];
struct KSEMASTBATCH *kse1[1024];
struct KSEMASTBATCH *kse2[1024];
struct KSEMASTBATCH *kse3[1024];
struct KSEMASTBATCH *kse_src[1024];
struct KSEMASTBATCH *kse_tmp;
struct KSEMASTBATCH kse_1_address[1024];
struct KSEMASTBATCH kse_2_address[1024];
int ii,kk,mm,ff,jj,cnt;
if(argc != 2)
{
return(-1);
}
if((fp=fopen(argv[1], "rt"))==NULL)
{
return(-1);
}
kk=0;
while(1)
{
memset(rbuf,0x00,sizeof(rbuf));
if(fgets(rbuf, sizeof(rbuf), fp)==NULL) break;
//STACK REGISTER & POINTER REGISTER
//STACK REGISTER & POINTER REGISTER
//STACK REGISTER & POINTER REGISTER
//STACK REGISTER & POINTER REGISTER
memcpy(&kse_1_address[kk], rbuf, SZ_KSEMASTBATCH);
memcpy(&kse_2_address[kk], rbuf, SZ_KSEMASTBATCH);
//[kse1 == kse2 == kse3] SAME ADDRESS POINTER
//[kse1 == kse2 == kse3] SAME ADDRESS POINTER
//[kse1 == kse2 == kse3] SAME ADDRESS POINTER
//[kse1 == kse2 == kse3] SAME ADDRESS POINTER
kse1[kk] = &kse_1_address[kk];
kse2[kk] = &kse_1_address[kk];
kse3[kk] = &kse_1_address[kk];
kse_src[kk] = &kse_2_address[kk];
kk++;
if(kk>1000) break;
}
cnt=kk;
if(fp != NULL) fclose(fp);
//ASCENDING SORT BY SYMBOL
//ASCENDING SORT BY SYMBOL
//ASCENDING SORT BY SYMBOL
for(kk=0; kk<cnt; kk++)
{
for(ii=kk+1; ii<cnt; ii++)
{
if(memcmp(kse1[kk]->stockcode,kse1[ii]->stockcode,sizeof(kse1[ii]->stockcode))>0)
{
kse_tmp=NULL;
kse_tmp = kse1[kk];
kse1[kk] = kse1[ii];
kse1[ii] = kse_tmp;
}
}
}
for(kk=0; kk<cnt; kk++)
{
printf("(1)[%.4d],SYM[%.12s]>>>>[%x][%.12s],[%x][%.12s]\n",
kk+1, kse_1_address[kk].stockcode, kse1[kk]->stockcode, kse1[kk]->stockcode, kse_src[kk]->stockcode,
kse_src[kk]->stockcode);
}
for(kk=0; kk<cnt; kk++)
{
printf("(2)[%.4d],SYM[%.12s]>>>>[%x][%.12s],[%x][%.12s]\n",
kk+1, kse_1_address[kk].stockcode, kse2[kk]->stockcode, kse2[kk]->stockcode, kse_src[kk]->stockcode,
kse_src[kk]->stockcode);
}
for(kk=0; kk<cnt; kk++)
{
printf("(3)[%.4d],SYM[%.12s]>>>>[%x][%.12s],[%x][%.12s]\n",
kk+1, kse_1_address[kk].stockcode, kse3[kk]->stockcode, kse3[kk]->stockcode, kse_src[kk]->stockcode,
kse_src[kk]->stockcode);
}
return(0);
}
/*결과
C:\Users\Downloads>src_0419 A0011.dat
(1)[0001],SYM[HK0000050325]>>>>[162f21][HK0000050325],[9af21][HK0000050325]
(1)[0002],SYM[KR5707017R97]>>>>[163241][KR5707017R97],[9b241][KR5707017R97]
(1)[0003],SYM[KR5713017R38]>>>>[163561][KR5713017R38],[9b561][KR5713017R38]
(1)[0004],SYM[KR571301A1B4]>>>>[163881][KR571301A1B4],[9b881][KR571301A1B4]
(1)[0005],SYM[KR5713027R36]>>>>[163ba1][KR5713027R36],[9bba1][KR5713027R36]
(1)[0006],SYM[KR5713037R34]>>>>[163ec1][KR5713037R34],[9bec1][KR5713037R34]
(1)[0007],SYM[KR571901A586]>>>>[1641e1][KR571901A586],[9c1e1][KR571901A586]
(1)[0008],SYM[KR572501A3B6]>>>>[164501][KR572501A3B6],[9c501][KR572501A3B6]
(1)[0009],SYM[KR572502A3B5]>>>>[164821][KR572502A3B5],[9c821][KR572502A3B5]
(1)[0010],SYM[KR572503A3B4]>>>>[164b41][KR572503A3B4],[9cb41][KR572503A3B4]
(2)[0001],SYM[HK0000050325]>>>>[162f21][HK0000050325],[9af21][HK0000050325]
(2)[0002],SYM[KR5707017R97]>>>>[163241][KR5707017R97],[9b241][KR5707017R97]
(2)[0003],SYM[KR5713017R38]>>>>[163561][KR5713017R38],[9b561][KR5713017R38]
(2)[0004],SYM[KR571301A1B4]>>>>[163881][KR571301A1B4],[9b881][KR571301A1B4]
(2)[0005],SYM[KR5713027R36]>>>>[163ba1][KR5713027R36],[9bba1][KR5713027R36]
(2)[0006],SYM[KR5713037R34]>>>>[163ec1][KR5713037R34],[9bec1][KR5713037R34]
(2)[0007],SYM[KR571901A586]>>>>[1641e1][KR571901A586],[9c1e1][KR571901A586]
(2)[0008],SYM[KR572501A3B6]>>>>[164501][KR572501A3B6],[9c501][KR572501A3B6]
(2)[0009],SYM[KR572502A3B5]>>>>[164821][KR572502A3B5],[9c821][KR572502A3B5]
(2)[0010],SYM[KR572503A3B4]>>>>[164b41][KR572503A3B4],[9cb41][KR572503A3B4]
(3)[0001],SYM[HK0000050325]>>>>[162f21][HK0000050325],[9af21][HK0000050325]
(3)[0002],SYM[KR5707017R97]>>>>[163241][KR5707017R97],[9b241][KR5707017R97]
(3)[0003],SYM[KR5713017R38]>>>>[163561][KR5713017R38],[9b561][KR5713017R38]
(3)[0004],SYM[KR571301A1B4]>>>>[163881][KR571301A1B4],[9b881][KR571301A1B4]
(3)[0005],SYM[KR5713027R36]>>>>[163ba1][KR5713027R36],[9bba1][KR5713027R36]
(3)[0006],SYM[KR5713037R34]>>>>[163ec1][KR5713037R34],[9bec1][KR5713037R34]
(3)[0007],SYM[KR571901A586]>>>>[1641e1][KR571901A586],[9c1e1][KR571901A586]
(3)[0008],SYM[KR572501A3B6]>>>>[164501][KR572501A3B6],[9c501][KR572501A3B6]
(3)[0009],SYM[KR572502A3B5]>>>>[164821][KR572502A3B5],[9c821][KR572502A3B5]
(3)[0010],SYM[KR572503A3B4]>>>>[164b41][KR572503A3B4],[9cb41][KR572503A3B4]
*/
//kse1, kse2, kse3는 같은 주소를 공유하므로, kse1이 변경되면 kse2, kse3도 참조하는 주소가 함께 변경(공유)되어진다.
//kse1, kse2, kse3는 같은 주소를 공유하므로, kse1이 변경되면 kse2, kse3도 참조하는 주소가 함께 변경(공유)되어진다.
//kse1, kse2, kse3는 같은 주소를 공유하므로, kse1이 변경되면 kse2, kse3도 참조하는 주소가 함께 변경(공유)되어진다.
//kse1, kse2, kse3는 같은 주소를 공유하므로, kse1이 변경되면 kse2, kse3도 참조하는 주소가 함께 변경(공유)되어진다.
//kse1, kse2, kse3는 같은 주소를 공유하므로, kse1이 변경되면 kse2, kse3도 참조하는 주소가 함께 변경(공유)되어진다.
//kse1, kse2, kse3는 같은 주소를 공유하므로, kse1이 변경되면 kse2, kse3도 참조하는 주소가 함께 변경(공유)되어진다.
//kse1, kse2, kse3는 같은 주소를 공유하므로, kse1이 변경되면 kse2, kse3도 참조하는 주소가 함께 변경(공유)되어진다.
//kse1, kse2, kse3는 같은 주소를 공유하므로, kse1이 변경되면 kse2, kse3도 참조하는 주소가 함께 변경(공유)되어진다.
/*SAMPLE DATA:A0011.dat
A0011HK000005032500000001A900050 중국원양자원 CHINA OCEAN 2016020400002FSN0000N00N1N00NNNNN000000000137105 00NN NNNNNNN NN NN NN000003305100000330500000228404100000000751338750500000429500000231500000231000000000000000000310020090522000000096359369N+000000000+000000N+000004765+000069NY00000000N0000000 000000000000000000001125666856000Y0000700007000010000700001000N0000000000000000000000000000000100001 HKD344NYYYYYY +00000000000 N NNNN000070000000 N N N0 NN NN
A0011KR5707017R9700000002F707017R9동양 강남대 1호 TongYang Kangnam 1 2016020400002BCN0000N00N1N00NNNNN N 07NNNNNNN NN NN NN000005000300000500000000000000000000000000000000000000650000000350000000352000000500000000000500020051209000000001010764N+000000000+000000 +000000000+000000 N00000000 00000002005091420170913 000000000000000000005053820000000N0000700000000000000000000000N0000000000000000000000000000000100000 KRW410NNNNNYY +00000000000 N NNNN000070000000 N N N0 NN NN
A0011KR5713017R3800000003F713017R3산은건대사랑1-1 KDBKonkukAsset1-1 2016020400003BCN0000N00N1N00NNNNN N 03NNNNNNN NN NN NN000005070300000507000000000000000000000000000000000000659000000355000000351000000500000000000500020050520000000002039243N+000000000+000000 +000000000+000000 N00000000 00000002005032820230327 000000000000000000010196215000000N0000700000000000000000000000N0000000000000000000000000000000100000 KRW410NNNNNYY +00000000000 N NNNN000070000000 N N N0 NN NN
A0011KR571301A1B400000004F71301A1BKDB월지급식안심튼튼제2호 KDB Anshim TeunTeun Fund No.2 2016020400004BCN0000N00N1N00NNNNN N 01NNNNNNN NN NN NN000000815300000081500000000000000000000000000000000000105500000057100000066000000100000000000100020120224000000010605957N+000000000+000000 +000000000+000000 N00000000 00000002011112820211128 000000000000000000010605957000000N0000700000000000000000000000N0000000000000000000000000000000100000 KRW410NNNNNYY +00000000000 N NNNN000070000000 N N N0 NN NN
A0011KR5713027R3600000005F713027R3산은건대사랑1-2 KDBKonkukAsset1-2 2016020400005BCN0000N00N1N00NNNNN N 03NNNNNNN NN NN NN000005050300000505000000000000000000000000000000000000656000000354000000351000000500000000000500020050520000000000620572N+000000000+000000 +000000000+000000 N00000000 00000002005032820230327 000000000000000000003102860000000N0000700000000000000000000000N0000000000000000000000000000000100000 KRW410NNNNNYY +00000000000 N NNNN000070000000 N N N0 NN NN
A0011KR5713037R3400000006F713037R3산은건대사랑2 KDBKonkukAsset2 2016020400005BCN0000N00N1N00NNNNN N 03NNNNNNN NN NN NN000005060300000506000000000000000000000000000000000000657000000355000000351000000500000000000500020050520000000002001000N+000000000+000000 +000000000+000000 N00000000 00000002005032820230327 000000000000000000010005000000000N0000700000000000000000000000N0000000000000000000000000000000100000 KRW410NNNNNYY +00000000000 N NNNN000070000000 N N N0 NN NN
A0011KR571901A58600000007F71901A58KB서울햇빛발전소특별자산 KB Seoul Solar Special Asset 2016020400004BCN0000N00N1N00NNNNN N 07NNNNNNN NN NN NN000001015300000101500000000000000000000000000000000000131500000071500000070000000100000000000100020151022000000008180797N+000000000+000000 +000000000+000000 N00000000 00000002015081720180703 000000000000000000008180797000000N0000700000000000000000000000N0000000000000000000000000000000100000 KRW410NNNNNYY +00000000000 N NNNN000070000000 N N N0 NN NN
A0011KR572501A3B600000008F72501A3B신한BNPP서울시지하철9호선1호 SHBNPP Seoul Metro 9 No.1 2016020400003BCN0000N00N1N00NNNNN N 07NNNNNNN NN NN NN000001020300000102000000000000000000000000000000000000132500000071500000070000000100000000000100020140221000000025000000N+000000000+000000 +000000000+000000 N00000000 00000002013112720180214 000000000000000000025000000000000N0000700000000000000000000000N0000000000000000000000000000000100000 KRW410NNNNNYY +00000000000 N NNNN000070000000 N N N0 NN NN
A0011KR572502A3B500000009F72502A3B신한BNPP서울시지하철9호선2호 SHBNPP Seoul Metro 9 No.2 2016020400002BCN0000N00N1N00NNNNN N 07NNNNNNN NN NN NN000001050300000105000000000000000000000000000000000000136500000073500000070000000100000000000100020140221000000025000000N+000000000+000000 +000000000+000000 N00000000 00000002013112720190214 000000000000000000025000000000000N0000700000000000000000000000N0000000000000000000000000000000100000 KRW410NNNNNYY +00000000000 N NNNN000070000000 N N N0 NN NN
A0011KR572503A3B400000010F72503A3B신한BNPP서울시지하철9호선3호 SHBNPP Seoul Metro 9 No.3 2016020400001BCN0000N00N1N00NNNNN N 07NNNNNNN NN NN NN000001000300000100000000000000000000000000000000000000130000000070000000070000000100000000000100020140221000000025000000N+000000000+000000 +000000000+000000 N00000000 00000002013112720200214 000000000000000000025000000000000N0000700000000000000000000000N0000000000000000000000000000000100000 KRW410NNNNNYY +00000000000 N NNNN000070000000 N N N0 NN NN
A0011KR572504A3B300000011F72504A3B신한BNPP서울시지하철9호선4호 SHBNPP Seoul Metro 9 No.4 2016020400001BCN0000N00N1N00NNNNN N 07NNNNNNN NN NN NN000001020300000102000000000000000000000000000000000000132500000071500000070000000100000000000100020140221000000025000000N+000000000+000000 +000000000+000000 N00000000 00000002013112720210216 000000000000000000025000000000000N0000700000000000000000000000N0000000000000000000000000000000100000 KRW410NNNNNYY +00000000000 N NNNN000070000000 N N N0 NN NN
A0011KR5737027S7500000012F737027S7PAM부동산3호 PAM Real Estate 3 2016020400001BCN0000N00N1N00NNNNN N 03NNNNNNN NN NN NN000005220300000522000000000000000000000000000000000000678000000366000000244000000500000000000500020090424000000027885679N+000000000+000000 +000000000+000000 N00000000 00000002006072020170220 000000000000000000139428395000000N0000700000000000000000000000N0000000000000000000000000000000100000 KRW410NNNNNYY +00000000000 N NNNN000070000000 N N N0 NN NN
A0011KR574401722300000013F74401722맵스프런티어브라질1 MiraeassetMAPSBrazilTrust 1 2016020400005BCN0000N00N1N00NNNNN N 03NNNNNNN NN NN NN000000480300000048000000000000000000000000000000000000062400000033600000020000000100000000000100020120511000000080000000N+000000000+000000 +000000000+000000 N00000000 00000002012021720181231 000000000000000000080000000000000N0000700000000000000000000000N0000000000000000000000000000000100000 KRW410NNNNNYY +00000000000 N NNNN000070000000 N N N0 NN NN
A0011KR700002000800000014A000020 동화약품 DongwhaPharm 2016020400002STN0000N00N1N00NNNNN000009000032102 03YN YNNNNNN NN NN NN000009510100000951000000161193900000001545183455000001235000000666000000665000000100000000000000019760324000000027931470N+000000177+005373N+000008225+000116NN00000080N0000008 000000000000000000027931470000000Y0000700007000010000700001000N0000000000000000000000000000000100001 KRW410NYYYYYY +00000000000 N NNNN000070000000 N N N0 NN NN
A0011KR700003000700000015A000030 우리은행 Woori Bank 2016020400005STN0000N00N1N00NNNNN000021022116401 61NY YYYNNNY NN NN NN000008580100000858000000096828500000000832510939000001115000000601000000686000000500000000001707620141119000000676000000N+000001621+000529N+000026592+000032NN00000500N0000058 000000000000000003381391855000000Y0000700007000010000700001000N0000000000000000000000000000000100001 KRW410NYYYYYY +00000000000 Y NNNN000080000000 N N Y0 YY NN
A0011KR700004000600000016A000040 KR모터스 KR MOTORS 2016020400005STN0000N00N1N00NNNNN000015000033109 03YN YNNNNNN NN NN NN000001175100000117500000182254600000000215271575000000152500000082500000082000000050000000000000019760525000000175307764N+000000000+000000N+000000385+000305NY00000000N0000000 000000000000000000087653882000000Y0000700007000010000700001000N0000000000000000000000000000000100001 KRW410NYYYYYY +00000000000 N NNNN000070000000 N N N0 NN NN
A0011KR700005000500000017A000050 경방 Kyungbang 2016020400002STN0000N00N1N00NNNNN000006000031301 82YN YNNNNNN NN NN NN000203000100020300000000000158100000000031873900000026350000014250000014210000000500000000000000019560303000000002741527N+000004190+004845N+000236250+000086NN00000500N0000002 000000000000000000013707635000000Y0000700007000010000700001000N0000000000000000000000000000000100001 KRW410NYYYYYY +00000000000 N NNNN000070000000 N N N0 NN NN
A0011KR700006000400000018A000060 메리츠화재 Meritz Insurance 2016020400005STN0000N00N1N00NNNNN000021025116501 02NN YNNNNNN NN NN NN000014800100001480000000010811800000000160339960000001920000001040000001036000000050000000000000019560702000000105963000N+000001131+001309N+000013190+000112NN00000380N0000026 000000000000000000052981500000000Y0000700007000010000700001000N0000000000000000000000000000000100001 KRW410NYYYYYY +00000000000 N YNNN000070000000 N N Y0 NN NN
A0011KR700007000300000019A000070 삼양홀딩스 SAMYANGHOLDINGS 2016020400003STN0000N00N1N00NNNNN000026000137105 72NN YNNNNNN NN NN NN000177000100017700000000002857900000000504358400000023000000012400000014160000000500000000000000019681227000000008564271N+000000327+054128N+000148290+000119NN00001500N0000008 000000000000000000042821355000000Y0000700007000010000700001000N0000000000000000000000000000000100001 KRW410NYYYYYY +00000000000 N NNNN000080000000 N N N0 NN NN
A0011KR700007100100000020A000075 삼양홀딩스우 SAMYANGHOLDINGS(1P) 2016020400001STN0000N00N1N00NNNNN000026000137105 00NN YNNNNNN NN NN NN000077800100007780000000000017700000000001351540000010100000005450000005446000000500000000000000019920221000000000304058N+000000000+000000Y+000000000+000000YN00001550N0000020 000000000000000000001520290000000Y0000700007000010000700001001N0000000000000000000000000000000100001 KRW410NYYYYYY +00000000000 N NNNN000070000000 N N N0 NN NN
A0011KR700008000200000021A000080 하이트진로 HITEJINRO 2016020400004STN0000N00N1N00NNNNN000005000031101 72YN YNNNNNN NN NN NN000030900100003090000000033727900000001036100460000004015000002165000002472000000500000000004100020091019000000070133611N+000000295+010475N+000018628+000166NN00001000N0000032 000000000000000000363168055000000Y0000700007000010000700001000N0000000000000000000000000000000100001 KRW410NYYYYYY +00000000000 N NNNN000080000000 N N N0 YY NN
A0011KR700008200800000022A000087 하이트진로2우B HITEJINRO(2PB) 2016020400004STN0000N00N1N00NNNNN000005000031101 00YN YNNNNNN NN NN NN000019500100001950000000000148600000000002878700000002535000001365000001365000000500000000000500020110926000000001130138N+000000000+000000Y+000000000+000000YN00001050N0000054 000000000000000000005650690000000Y0000700007000010000700001002N0000000000000000000000000000000100001 KRW410NYYYYYY +00000000000 N NNNN000070000000 N N N0 NN NN
*/
'c 언어 > 고급과정' 카테고리의 다른 글
[DirectX 12] 기본지식 - CPU / GPU 동기화 (0) | 2024.02.17 |
---|---|
DOS-HEXA(QUICK VIEW) (0) | 2020.08.07 |
포인터변수와 스택변수의 정렬비교, 주소참조 혹은 값참조 (0) | 2019.10.31 |
HASH TABLE을 이용한 KEY,VALUE 컨트롤(KEY개수 65536개까지) (0) | 2019.10.31 |
포인터변수 + 스택변수를 이용한 해쉬테이블 사용예제(해쉬테이블 2개사용예제) + 수식에 콤마 추가 (0) | 2019.10.31 |