/////////////////////////////////////////
// A prog. make my work easier
// during scanning the barcode
// of the module.
// Ver 1.0
// Writer: Qian Xin on 2008.4.23
////////////////////////////////////////
#include<stdio.h>
#include<stdlib.h>
int main(int argc, char *argv[])
{
// 46 modules in fact, but 4 modules for buff
// Every barcode has 1 char and 8 ints
// 10 makes 1 buff in barcode
// barcode example: s30201234
char strBarcode[50][10];
int nModuleNumber=0;
//print paras
printf("%d para\n",argc);
for (int i=0;i<argc;i++) printf ("para[%d]:%s\n",i,argv[i]);
FILE *in,*out;
// file to read
if (!(in=fopen(argv[1],"r")))
{
printf("Read Error!\n");
system("pause");
return 1;
}
// file to write
if (!(out=fopen("out.txt","w")))
{
printf("Write Error!\n");
system("pause");
return 1;
}
// read from file
while(fscanf(in,"%s",&strBarcode[nModuleNumber]) != EOF)
nModuleNumber++;
// converting
if (nModuleNumber != 46)
{
printf ("There are %d modules!\n",nModuleNumber);
printf ("Please check it out!\n");
}
else
{
printf ("Success!\n");
}
// write to the file removing every first character of the string
for (int i=0;i<nModuleNumber;i++)
{
fprintf(out,"%s",strBarcode[i]+1);
fprintf(out,"\n");
}
system ("pause");
fclose(in);
fclose(out);
return 0;
}
[[it] 本帖最后由 SNAKEQX 于 2008-4-23 18:16 编辑 [/it]]