better still, you could declare a structure as per the requirements and write it to files
Code:
#define STR_SIZE 20
typedef struct {
char string[STR_SIZE];
int a;
int b;
int c;
}DATA;
FILE *fp;
DATA *item;
fp = fopen("filename.txt", "w+");
...
...
item = malloc(sizeof *item);
...
...
strcpy(item->string, "Hello");
item->a = 10;
item->b = 20;
item->c = 30;
fwrite(item,sizeof(*item),1,fp);
...
...
{
DATA *temp;
FILE *rfp;
temp = malloc(sizeof *temp);
rfp = fopen("filename.txt", "r");
fread(temp,sizeof(*temp),1,rfp);
printf("%s %d %d %d\n", temp->string, temp->a, temp->b, temp->c);
}
...
...
cheers
maverix