is this the correct/best way to set file size?
Hello everyone,
I have verified that the following approach works to set the size of a file (newly created file) to be 100 bytes, but I am not sure whether it is the correct/best way to have a maximum portability (I need to write code on both Windows and Linux).
Could anyone give me any comments?
Code:
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <io.h>
#include <stdio.h>
int main()
{
FILE* file = fopen ("foo123", "w+");
fseek (file, 99, SEEK_SET);
fprintf (file, "x");
fclose (file);
return 0;
}
thanks in advance,
George