All pastes #949629 Raw Edit

Miscellany

public text v1 · immutable
·published 2008-03-19 22:30 UTC
rendered paste body
void batch()
{
	FILE *originals ;
	FILE *output ;
	char file_input[50];
	char file_output[50];
	printf("input numbers filename?\n");
	scanf("%s", &file_input);
	printf("output numbers filename?\n");
	scanf("%s", &file_output);
	originals = fopen(file_input, "r");
	output = fopen(file_output, "a");
	char ean_str[14], isbn_str[11];
	int ean[14], i;
	while (fgets(ean_str, 14, originals))
	{
		fputc(13, output);
		/*use custom conversion function to make an int array from the input */ 
		for (i=0; i<=12; i++)
		{
			ean[i] = get_digit(ean_str[i]);
		}
		/*convert the EAN number to an ISBN and convert the returned integer to a string*/
		sprintf(isbn_str, "%07d", ean_to_isbn(ean));
		/*write the string to the output file specified*/
		fputs(isbn_str, stdout);
		/*write a newline to the file*/
		fputc(13, stdout);
	}
	fclose(originals);
	fclose(output);
	printf("done!\n");
	
}