Does anybody know how to output the results to a file instead of printf ob the screen? Thanks
The following is a bit of my code:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
void direction()
{
float a, b, c;
int x1,y1,z1,x2,y2,z2;
int u1, v1, w1, u2, v2, w2;
float I_u1v1w1, I_u2v2w2;
float phi;
float L;
float alpha, beta, gama;
char ch, discard;
printf("---Caculating the angle between zone axis---\n");
do
{
printf("Enter the lattice parameters(postive integer):");
printf("\na=");
scanf("%f", &a);
discard = getchar();
printf("b=");
scanf("%f", &b);
discard = getchar();
printf("c=");
scanf("%f", &c);
discard = getchar();
printf("alpha=");
scanf("%f", &alpha);
discard = getchar();
printf("beta=");
scanf("%f", &beta);
discard = getchar();
printf("gama=");
scanf("%f", &gama);
discard = getchar();
printf("\nEnter the number of (u1 v1 w1):");
scanf("%d %d %d", &u1, &v1, &w1);
discard = getchar();
printf("\nEnter the number of (u2 v2 w2):");
scanf("%d %d %d", &u2, &v2, &w2);
discard = getchar();
alpha = alpha * PI/180;
beta = beta * PI/180;
gama = gama * PI/180;
printf("\nu1v1w1\tu2v2w2\tphi");
for(x1=-u1; x1<=u1; x1++)
{
for(y1=-v1; y1<=v1; y1++)
{
for(z1=-w1; z1<=w1; z1++)
{
for(x2=-u2; x2<=u2; x2++)
{
for(y2=-v2; y2<=v2; y2++)
{
for(z2=-w2; z2<=w2; z2++)
{
L = a*a*x1*x2 + b*b*y1*y2 + c*c*z1*z2 + b*c*(y1*z2+z1*y2)*
cos(alpha) + a*c*(z1*x2 + x1*z2)*cos(beta) + a*b*(x1*y2+y1*x2)*cos(gama);
I_u1v1w1 = a*a*x1*x1 + b*b*y1*y1 + c*c*z1*z1 + 2*b*c*y1*z1*
cos(alpha) + 2*c*a*x1*z1*cos(beta) + 2*a*b*x1*y1*cos(gama);
I_u2v2w2 = a*a*x2*x2 + b*b*y2*y2 + c*c*z2*z2 + 2*b*c*y2*z2*
cos(alpha) + 2*c*a*x2*z2*cos(beta) + 2*a*b*x2*y2*cos(gama);
phi = acos( L/sqrt(I_u1v1w1*I_u2v2w2)) * 180/PI;
printf("\n%d%d%d\t%d%d%d\t%.3f",
x1,y1,z1,x2,y2,z2,phi);
}
}
}
}
}
}
getchar();/*to remove the effect of "Enter" when input 'y' or 'n'*/
printf("\ncomputer more?(y/n)");
scanf("%c",&ch);
} while(ch == 'y');
}