Who can help me to find the wrong of the vtr output by my own code

void VTK_output(int nx, int ny, int **wall2)
{
nx = nx + 4;
ny = ny + 4;

printf("start saving the VTK file ! \n");
FILE *wallvtk;
wallvtk = fopen("wallvtk.vtr", "w");

fprintf(wallvtk, "<?xml version=\"1.0\"?>\n");
fprintf(wallvtk, "<VTKFile type=\"RectilinearGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n");
fprintf(wallvtk, "<RectilinearGrid WholeExtent=\"%d %d %d %d %d %d\">\n", 0, nx - 1, 0, ny - 1, 0, 0);
fprintf(wallvtk, "<Piece Extent=\"%d %d %d %d %d %d\">\n",0,nx-1,0,ny-1,0,0);
fprintf(wallvtk, "<PointData>\n");
fprintf(wallvtk, "<DataArray type=\"Float32\" Name=\"walltype\" format=\"appended\" offset=\"%d\" />\n", 0);
fprintf(wallvtk, "</PointData>\n");
fprintf(wallvtk, "<Coordinates>\n");
fprintf(wallvtk, "<DataArray type=\"Float32\" Name=\"x\" format=\"appended\" offset=\"%d\" />\n", (nx*ny + 1) * sizeof(float));
fprintf(wallvtk, "<DataArray type=\"Float32\" Name=\"y\" format=\"appended\" offset=\"%d\" />\n", (nx*ny + 1) * sizeof(float)+(nx + 1)* sizeof(float));
fprintf(wallvtk, "<DataArray type=\"Float32\" Name=\"z\" format=\"appended\" offset=\"%d\" />\n", (nx*ny + 1) * sizeof(float)+(nx + 1)* sizeof(float)+(ny + 1) * sizeof(float));
fprintf(wallvtk, "</Coordinates>\n");
fprintf(wallvtk, "</Piece>\n");
fprintf(wallvtk, "</RectilinearGrid>\n");
fprintf(wallvtk, "<AppendedData encoding=\"raw\">\n");
fprintf(wallvtk, "_");

printf("VTK file title write ok! \n");

    unsigned int a = nx*ny * sizeof(float);
	fwrite(&a, sizeof(unsigned int), 1, wallvtk);

	for (int i = 0; i<nx; i++)
	for (int j = 0; j<ny; j++)
	{
		float wall_type = wall2[i][j];
		fwrite(&wall_type, sizeof(float), 1, wallvtk);
	//	printf(" writing ok! \n");
	}

	unsigned int b = nx * sizeof(float);
	fwrite(&b, sizeof(unsigned int), 1, wallvtk);
	for (int i = 0; i < nx; i++)
	{
		float tmp = i;
		fwrite(&tmp, sizeof(float), 1, wallvtk);
	}


	unsigned int c = ny* sizeof(float);
	fwrite(&c, sizeof(unsigned int), 1, wallvtk);
	for (int j = 0; j < ny; j++)
	{
		float tmp = j;
		fwrite(&tmp, sizeof(float), 1, wallvtk);
	}

	unsigned int d = sizeof(float);
	fwrite(&d, sizeof(unsigned int), 1, wallvtk);
	float z = 0;
	fwrite(&z, sizeof(float), 1, wallvtk);

	fprintf(wallvtk, "\n");
	fprintf(wallvtk, "</AppendedData>\n");
	fprintf(wallvtk, "</VTKFile>\n");
	

	fclose(wallvtk);

	printf("VTK file write ok ! \n");

}
The output file open have wrong like this picture.

Hello,

I am not familiar with the vtr format. Would you have the specifications somewhere? Are you trying to implement this in Palabos?