Hi now i created my code...but with lots of error..pls. correct me...at least now can anyone help me out...
my input file looks like this:
0 1212.23
1 2323.45
2 5985.555
3 3778.7812
4 45.56
. .
. .
. .
(N-1) .
that is two columns...if the last number in 1st column is (N-1), then the total no. of points is (N)...hope u understand...Now i need to make the following conversion to column one:-
2*V*(i-Z)/(N-1), where V = is some no. for e.g., 5.786, and Z = 456.5643356 and (N-1) is the last no. of column one or total no. of data points. And i=0,1,2,3,...(N-1).
Also for the second column i have to do the following conversion:-
(M*100/K), where M is the values in second columns (for e.g., 1212.23, 2323.45, etc.) and K is some number for e.g., 12312555.5555567.
So in the command line i need to type the exe file name, input files name, output file, Z, V and K.
Here my code:-
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define LNGMAX 1500
int main(int argc, char **argv)
{
FILE *fpein,*fpaus;
char *fs,datein[LNGMAX],dataus[LNGMAX],zeile[LNGMAX];
double V,Z
int ndat
if (argc != 6)
{
puts(" !!! Aufruf: vel <datein> <dataus> <Z> <V> <K> ");
puts(" ... Z : 57Fe's zero velocity channel");
puts(" ... V : Drive velocity in mm/s");
return(-1);
}
strcpy(datein,argv[1]);
if ( (fpein=fopen(datein,"r")) == NULL )
{ printf("\n !!! Error %s cannot open\n",datein);
return(-1); }
strcpy(dataus,argv[2]);
if ( (fpaus=fopen(dataus,"w")) == NULL )
{ printf("\n !!! Error %s cannot open\n",dataus);
return(-1); }
sscanf(argv[3],"%lf",&Z);
sscanf(argv[4],"%lf",&V);
sscanf(argv[5],"%lf",&K);
/* det. no. of data points */
i=0;
do {
fg=fgets(zeile,LNGMAX,fpein);
sscanf(zeile,"%lf" %lf\n",&x[i],&y[i]);
i++;
} while (fg!=NULL);
fclose(fpein);
ndat = i-1;
for i=0;i<=LNGMAX;i++)
i=0;
do {
x[i]=2*V*(i-Z)/(ndat-1);
i++;
} while (fg!=NULL);
do {
i=0;
y[i]=i/K;
} while (fg!=NULL);
fprintf ( fpaus," %lf %lf\n", x[i],y[i]);
fclose(fpaus);
puts("....Done");
return(0);
}
correct this c code..
thanks
Kumar.#