#include #include #include #define MAXCHARS 200 typedef struct { char *pszName; int nNORADId; } SATSTRUCT, *PSATSTRUCT; static SATSTRUCT ass[]= { {"AO-07",7530}, {"AO-10",14129}, {"UO-11",14781}, {"RS-10/11",18129}, {"FO-20",20480}, {"RS-12/13",21089}, {"RS-15",23439}, {"FO-29",24278}, {"SO-33",25509}, {"AO-40",26609}, {"UO-14",20437}, {"AO-16",20439}, {"WO-18",20441}, {"LO-19",20442}, {"UO-22",21575}, {"KO-23",22077}, {"AO-27",22825}, {"IO-26",22826}, {"KO-25",22828}, {"TO-31",25396}, {"GO-32",25397}, {"UO-36",25693}, {"AO-37",26065}, {"SO-41",26545}, {"MO-46",26548}, {"SO-42",26549}, {"NO-44",26931}, {"AO-49",27605}, {"SO-50",27607}, {"PO-34",25520}, {"ISS",25544}, {"WO-39",26061}, {"OO-38",26063}, {"NO-45",26932}, {"AO-51",28375}, {NULL,0} }; void main(void) { char szLine0[MAXCHARS+1]=""; char szLine1[MAXCHARS+1]=""; char szLine2[MAXCHARS+1]=""; char *psz0=szLine0; char *psz1=szLine1; char *psz2=szLine2; while (!feof(stdin) && !ferror(stdin)) { char *psz=psz0; psz0=psz1; // Rotate the strings psz1=psz2; psz2=psz; if (fgets(psz2,MAXCHARS,stdin)!=NULL) { if (strncmp(psz1,"1 ",2)==0 && strncmp(psz2,"2 ",2)==0 && strncmp(psz1+2,psz2+2,5)==0) { PSATSTRUCT pss; char szNORADId[6]; int nNORADId; strncpy(szNORADId,psz1+2,5); szNORADId[5]='\0'; nNORADId=atoi(szNORADId); for (pss=ass;pss->nNORADId!=0 && pss->nNORADId!=nNORADId;pss++) { } if (pss->nNORADId==nNORADId) { strcpy(psz0,pss->pszName); strcat(psz0,"\n"); } fprintf(stdout,"%s1 %05d%s2 %05d%s",psz0,nNORADId,psz1+7,nNORADId,psz2+7); } } } if (ferror(stdin)) { fprintf(stderr,"Error reading file\n"); } else { fprintf(stderr,"Process completed successfully\n"); } }