Easy method of Writing And Reading Small Text File
Easy method of Writing And Reading Small Text Files
AI
Yapay Zeka Özeti: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Kaynak Kod
I wrote the following two functions to go between strings and text files in my apps:
public Function ReadFile(FileName as string) as string
Dim i as Integer
i = FreeFile
on error GoTo ErrorTrap
Open FileName for input as #i
ReadFile = input(LOF(i), i)
Close #i
Exit Function
ErrorTrap:
ReadFile = ""
End Function
public Sub WriteFile(FileName as string, Contents as string)
Dim i as Integer
i = FreeFile
Open FileName for Output as #i
print #i, Contents
Close #i
End Sub
***Once these functions are in your project, you have a quick way of reading and writing text files. For example, the following code is a weird way of copying text files:
Call WriteFile("c:\b.txt", ReadFile("c:\a.txt"))
#include <windows.h>
#include <mmsystem.h>
#pragma comment(lib,"winmm.lib")
#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
int main(void)
{
PlaySound("SystemStart",NULL, SND_ALIAS|SND_SYNC);
Sleep(50);
PlaySound("SystemStart",NULL, SND_ALIAS|SND_SYNC);
Sleep(50);
PlaySound("SystemStart",NULL, SND_ALIAS|SND_SYNC);
Sleep(50);
return 0;
}
Orijinal Yorumlar (3)
Wayback Machine'den kurtarıldı