Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
26
Добавлен:
17.04.2013
Размер:
691 б
Скачать
#include"file.h"
#include<string.h>

file::file(char *fname, char *mode)
{
	name=new char[strlen(fname)+1];
	strcpy(name,fname);
	cont=fopen(name,mode);
}

file::~file()
{
	fclose(cont);
	delete name;
}

file *file::operator +(file &f)
{
	char c;

	fseek(cont,0,2);
	fseek(f.cont,0,0);

	c=getc(f.cont);
	while (!feof(f.cont))
	{
		putc(c,cont);
		c=getc(f.cont);
	}

	return this;
}

file* file::operator =(file &f)
{
	char c;

	if (f.cont==NULL)
		return NULL;
	else
	{
		fclose(cont);
		cont=fopen(name,"w");
		fseek(f.cont,0,0);
		c=getc(f.cont);
		while (!feof(f.cont))
		{
			putc(c,cont);
			c=getc(f.cont);
		}
	}

	return this;
}
Соседние файлы в папке Var12