mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
Initial import into SourceForge CVS
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14685 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
44
test_programs/iotest.c
Normal file
44
test_programs/iotest.c
Normal file
@ -0,0 +1,44 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define FILE_SIZE 2048
|
||||
#define WRITE_SIZE 32
|
||||
|
||||
char FileData[FILE_SIZE];
|
||||
|
||||
void CreateFile(char *filename)
|
||||
{
|
||||
FILE *file;
|
||||
|
||||
if (file = fopen(filename,"w")) {
|
||||
memset(FileData,'0',FILE_SIZE);
|
||||
memset(FileData,'-',WRITE_SIZE);
|
||||
fwrite(FileData,1,FILE_SIZE,file);
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
|
||||
void ReadWriteFile(char *filename)
|
||||
{
|
||||
FILE *file;
|
||||
|
||||
if (file = fopen(filename,"r+")) {
|
||||
fseek(file,0,SEEK_SET);
|
||||
fread(FileData,1,FILE_SIZE,file);
|
||||
fseek(file,0,SEEK_SET);
|
||||
memset(FileData,'1',WRITE_SIZE);
|
||||
fwrite(FileData,1,WRITE_SIZE,file);
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc > 1) {
|
||||
CreateFile(argv[1]);
|
||||
ReadWriteFile(argv[1]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user