cpp Defines the entry point for the console application include stdafx

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// 9.3.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#define eof '#'
int _tmain()
{
wchar_t *s = (wchar_t *) malloc(1024);
if (s == NULL)
{
wprintf((const wchar_t *) "Insufficient memory available for name\n");
return(0);
}
wchar_t *name=(wchar_t *)malloc(1024);
if (name == NULL)
{
wprintf((const wchar_t *) "Insufficient memory available for name\n");
return(0);
}
name=L"e:\\2008-Uni.txt";
FILE *fp;
if ((fp = _wfopen(name, L"w")) == NULL)
{
wprintf(L"Open File Error\n");
return(0);
}
while (1)
{
wchar_t *p=fgetws( s, 1024, stdin);
if (p == NULL)
{
wprintf(L"fgets error\n");
return(0);
}
if (*p == eof)
{
fclose(fp);
return(0);
}
int i=fputws(s, fp);
if(i < 0)
{
wprintf(L"fputs error\n");
return(0);
system("PAUSE");
}
}
}