#include<stdio.h>
#include<conio.h>
#include<stdlib.h>

int main()
{
	 FILE *in;	// -> ´ ©«®¢ ³ª § ²¥«
	 FILE *out;
	 int br=0;
	 int ch;
	 char fname;

	 clrscr();	// -> ¨§²°¨¢  ¯®²°¥¡¨²¥«±ª¨¿ ¥ª° ­
	 printf("This program count numbers of rows in file '*.C'\n"
		"and write a simbols in new file:datanew.txt\n"
		"----------------------------------------------------------------\n");
	 printf("Open file:");
	 scanf("%s", fname);
	 in = fopen("fname","rt"); //-> ®²¢ °¿ ²¥ª±²®¢¨¿ ´ ©« dataold.txt
	 if (in == NULL) {
		printf("\nCan't open file: %s for reading", &fname);
		getch();
		return(0);
		}

	 out = fopen("datannew.txt","w+t");
		if (out == NULL){
			puts("\nCan't create a file:datanew.txt");
			getch();
			return(0);
			}


	 do {

		ch=getc(in); /* ¯°®·¨² ­¥ ­  ±¨¬¢®« ®² ¢µ®¤­¨¿ ´ ©« */
		printf("%c",ch);
		putc(ch,out); /* ´ ©« dataout.txt */
			      /* ´ ©« dataout.txt */
		if(ch=='\0')
			br++;
	 } while (ch!=EOF); /* ¤® ¤®±²¨£ ­¥ ª° © ­  ´ ©«  */

	 fclose(in); /* § ²¢ °¿­¥ ­  ´ ©«   */
	 fclose(out);

	 printf("\nThe count number is:",br-1);
	 getch(); //-> § ¤·°¦  ¯®²°¥¡¨²¥«±ª¨¿ ¥ª° ­
	 return (0);
}