/*
第2種情報処理技術者試験 平成7年度・春期・午後 問11 プログラム2
BohYoh Shibata PREPARATION
*/
#include <stdio.h>
#include <string.h>
typedef struct{
char name[16],relt[8],mode[4][4],tel[16],zip[8],addr[32];
} ADR;
#define SIZ 70
main()
{
FILE *fp;
ADR rbuf;
char obuf[3][SIZ];
int wi , eid , wide;
fp = fopen( "jusho.txt" , "r" );
wide = sizeof( rbuf.addr );
while ( 1 ) {
for ( wi=0; wi<3; wi++ ) {
memset( &obuf[wi] , ' ' , SIZ );
obuf[wi][SIZ-1] = '\0';
}
for ( eid=0 ; eid < SIZ / wide; eid++ ) {
if ( fgets( (char*)&rbuf , sizeof(ADR) , fp) == NULL ) {
fclose( fp );
return;
}
strncpy( obuf[0]+eid*wide , rbuf.zip , sizeof(rbuf.zip) );
strncpy( obuf[1]+eid*wide , rbuf.addr , sizeof(rbuf.addr)-2 );
strncpy( obuf[2]+eid*wide , rbuf.name , sizeof(rbuf.name) );
strncpy( obuf[2]+eid*wide+sizeof(rbuf.name) , "様" , 2 );
}
printf( "\n\n\n" ); /* 空行の出力 */
for ( wi=0; wi<3; wi++ ) printf( "%s\n" , obuf[wi] );
}
}