fopen()

fopen(const char *filename, const char *access_mode)

//access_mode
//	"r"  Open a file for reading. The file must exist.
//	"r+" Open a file for reading and writing. The file must exist.
//	"w"  Create an empty file for writing. If a file with the same name already exists its content is erased.
//	"w+" Create an empty file for writing and reading. If a file with the same name already exists its content is erased before it is opened.
//	"a"  Append to a file. Write operations append data at the end of the file. The file is created if it doesn’t exist.
//	"a+" Open a file for reading and appending. All writing operations are done at the end of the file protecting the previous content from being overwritten. You can
//		 reposition (fseek) the pointer to anywhere in the file for reading, but writing operations will move back to the end of file. The file is created if it doesn’t exist.

fseek

	if (fseek(File1, (long int)MyOffset, SEEK_SET) != 0)			//SEEK_SET=Beginning of file, SEEK_CUR=Current position, SEEK_END=End of file.  Returns 0 if successful, non-zero = failed
	{
		//Failed
	}

ftell – get current position in file as an int

long int ftell(FILE *stream)

	int FileBytePosition = ftell(File1)
	if (FileBytePosition == -1)
	{
		//Error

	}
	else if (FileBytePosition == 0)
	{
		//At start of file

	}

fgetpos

fsetpos

rewind

fclose

remove

rename

clearerr

feof

ferror

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *