Gday all,

I'm trying to get all this file processing under control and i am having a bit of trouble.

I think i can create a file ok and store information into it, but i'm not sure if there is a simple way to print out the contents of a file.
This is whats happening

Code:
#include <stdio.h>
#include <stdlib.h>

int main()
{

	FILE *fp;
	int i;

	if((fp = fopen("clients.dat", "r+w")) == NULL)

		printf("Error in opening the file\n");
	else
		printf("FILE IS OPEN\n");

	for (i = 1;i<=10;i++)
			fprintf(fp, "i = %d\n", i);



	fclose(fp);

}
I understand that this creates a file called clients.dat for writing to. Firstly, i havent been able to get the file to open at all.
Code:
if((fp = fopen("clients.dat", "r+w")) == NULL)
This constantly seems to return a NULL value.

In the event that it would open and the information would be entered through the FOR loop, im not sure what to include in the code which would print out the contents of the file

e.g.

FILE IS OPEN
1
2
3
4
5
6
7
8
9
10


in pretty sure there is a simple way to approach this, possibly with the use of fscanf, or fread or something of the like, but i'm just not sure.

Sorry, but on the topic, when would a function like fseek be used?
What is its purpose?
Is it only when dynamic memory is allocated using malloc() and it goes to a certain point of memory in the file?

Thanks if anyone can help.