_creat and _write easier thean Create and Write
Code:
// StringSave.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "io.h"
#include "fcntl.h"
#include "sys\stat.h"
#include "string.h"
int main(int argc, char* argv[])
{
int hFile = _creat("test.txt", _S_IWRITE|_S_IREAD);
char* pszTxt = "This is my test Text!!";
_write(hFile, pszTxt, strlen(pszTxt));
_close(hFile);
hFile = _open("test.txt", _O_RDONLY);
_lseek(hFile, 0L, SEEK_END);
int nLen = _tell(hFile)-1;
char szBuf;
while(nLen>=0)
{
_lseek(hFile, nLen--, SEEK_SET);
_read(hFile, &szBuf, 1);
_write(1, &szBuf, 1);
}
return _close(hFile);
}
//StdAfx.h is just like the normal built in file
Hope it works.