Example #1
0
bigInt ReadFromTextFile(const char *fileName)
{
	FILE *fp = fopen(fileName, "r");
	if (!fp)
	{
		// если файл не открылся
		bigInt res;
		res.sizeNum = 0;
		res.sign = 0;
		res.digits = NULL;
		return res;
	}

	// узнаем размер файла
	fseek(fp, 0, SEEK_END);
	int filesizeNum = ftell(fp);
	fseek(fp, 0, SEEK_SET);

	// считываем содержимое файла
	char* fileContent = (char*)malloc(filesizeNum + 1);
	fscanf(fp, "%s", fileContent);
	fileContent[filesizeNum] = '\0';
	fclose(fp);
	bigInt res = createFromString(fileContent);
	free(fileContent);
	return res;
}
Example #2
0
text::text(const string& t)
{
	createFromString(t, charset::getLocalCharset());
}
Example #3
0
text::text(const string& t, const charset& ch)
{
	createFromString(t, ch);
}