convert file.data into file.text or file.xml (better)

dear all,

I created a file.dat whit this function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
    int writeData(double* v, int length, FILE* fh)
    {
    	FILE *Stream;					//Stream for output.
    	double*Elem;					//Pointer to all the element to save.
    
    	assert( fh!=NULL );
    	Stream = fh;
    
    	Elem=(double*)malloc((length+2)*sizeof(double));//Allocate memory to Elem.
    	if(Elem==NULL)
    	{
    		printf("Can't allocate memory for saving the matrix!");
    		return(0);
    	}
    
    	Elem[0]=(double)1;//Save the dimensions of the matrix.
    	Elem[1]=(double)length;
    
    	int i;
    	for(i=0;i<length ;i++) Elem[i+2]=v[i];
    
    	if(fwrite((void*)Elem,sizeof(double),(length+2),Stream) < (unsigned)(length+2)) //Save the data.
    	{
    		printf("Error, can't save the matrix!");
    		return(0);
    	}
    	free(Elem);
    	return(1);

now I'd like to convert this file into an xml one or into a text file...

any tips?
thanks
Topic archived. No new replies allowed.