[ create a new paste ] login | about

Link: http://codepad.org/sCMhR5yl    [ raw code | fork ]

C++, pasted on Aug 24:
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>


int main()
{

	FILE * r = fopen("read.txt", "rt");
	FILE * w = fopen("write.txt", "wt");
	int i;


	if (!r)
	{
		wprintf(L"ERROR: Cannot open file\n");
		system("pause");
		return 0;
		
	}
	int m = -1;
	while (!feof(r))
	{
		wchar_t x;
		fwscanf(r, L"%c", &x);
		m++;
	}
	rewind(r);
	printf("m=%d\n", m);
	wchar_t *a = (wchar_t *)malloc(m * sizeof(wchar_t));
	for (i = 0; i<m; i++)
	{
		fwscanf(r, L"%c", &a[i]);
	}
	for (i = 0; i < m; i++)
	{
		fwprintf(w,L"%c", a[i]);
	}

	system("pause");
	fclose(r);
	fclose(w);
}


Create a new paste based on this one


Comments: