Writing a file in C

Hi All
I am new to C and trying to write a code to get a file as an output.
My text file should look like:
<var1>tab<var2>tab<var3>...upto the elements in an array
<varb1>tab<varb2>tab<varb3>...upto the elements in an array

Can someone please guide me how to write the code or a sample program will help me a lot...

Any kind of help is really appreciated.

Thanks
Amit

It's hard to be specific unless you show us what you've written. Array of what?

You really should look a bit on google before posting here, you could have found your answer with a very simple google search.

In any case, in C this is an example of file io

#include <stdio.h>
main()
{
int i=5;
FILE *fp;
fp = fopen ("output.txt","w");
fprintf(fp,"%d\t",i);
return 0;
}

the "w" is the open mode, open for writing. "r" would be open for reading.
fprintf works exactly like printf except you have the reference to the open file as the first argument.

To print your arrays I would recommend using for loops, \t is tab character \n is newline.
Good luck.

#include <stdio.h>
#define NUMELEMENTS 100

int main(){

int elements[NUMELEMENTS];
int idx;
FILE *fp;

///... initialize your array elements...

fp = fopen("output.txt", "w");
for(idx = 0; idx < NUMELEMENTS; i++){
  fprintf("%d\t", elements[idx]);
}

fclose(fp); //never forget this
return 0;
}

[/FONT]