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

int main(int argc, char *argv[])
{
	if(argc != 3)
	{
		fputs("err! no input!\n\n", stderr);
		exit(1);
	}

	unsigned long num;
	int idx;
	int location;

	char buffer[1+1];
	char fnm[70]; memset(fnm, 0x00, sizeof(fnm));
	FILE *fp = NULL;

	num = atol(argv[1]);

	idx = num/100000000;
	location = num%100000000;
	
	if( location == 0 )
	{
		idx--;
		location = 100000000; 	
	}

        //sprintf(fnm, "/home2/app_data/tcs/BASEINFO/PLBASE/PLMST%.03d", idx);
          sprintf(fnm, "/home2/app_data/tcs/BASEINFO/PLTPCARDMST");

	fp = fopen(fnm, "r+");
	if(fp == NULL)
	{
		printf("File error!(%s)\n", fnm);
		return 0;
	}
	
	fseek(fp, location-1, SEEK_SET);
	fread(buffer, sizeof(char), 1, fp);

 	printf("파일명 : %s\n", fnm);
	printf("위치값 : %d\n", location);
	printf("변경 : %c -> %s\n\n", *buffer, argv[2]);

	fseek(fp, location-1, SEEK_SET);
	fprintf(fp, argv[2]);


	fclose(fp);

	return 0;
}
