#include <stdio.h>
#include <conio.h>
void del_N(int N) {
int c,row_index=0,symbol_index=0,i=0,j=0,s=0,d=0,z=0,l=0,counter=0,povtor=0,k=0,n=1,p=0;
char mas[10][20],*str1;
char ch;
int flag=0;
FILE *read,*result;
if((read=fopen("R:\\tmp\\test.txt","r"))==NULL){printf("ERROR");}
if((result=fopen("R:\\tmp\\result.txt","w")) == 0){printf("ERROR");}
str1=&mas[0][0];
while((ch=fgetc(read))!=EOF)
{
if ((ch == ' ')) {
mas[row_index][symbol_index]='\0';
++row_index;
symbol_index = 0;
} else {
mas[row_index][symbol_index] = ch;
++symbol_index;
}
mas[row_index][symbol_index] = '\0';
//out
//in
for (i=0;mas[N]
='\0';i++){
mas[N]='\b';
}
//out
//in
if(ch=='\n'){
if(flag==1){printf("Result:\n>");flag=0;}
for(j=0;j <= row_index;j++){
for (i=0;mas!='\0';i++){
fprintf(result,"%c",mas);
printf("%c",mas);
}
fprintf(result," ");
printf(" ");
}
row_index=0;
symbol_index=0;
if(p<1){flag=1;p++;}
}
//out
}//out_while
fclose(read);
fclose(result);
}
int main(void)
{
int i=0,j=0,N=0;
char x[256],*str;
FILE *create_write;
if((create_write=fopen("R:\\tmp\\test.txt","w")) == 0){printf("ERROR");}
str=&x[0];
//in
printf("Enter the number of lines:\n>");
scanf("%d",&j);
printf("Enter the string:\n>");
while(i<=j){
gets(str);
fputs(str,create_write);
fputs("\n",create_write);
i++;
}
fclose(create_write);
//out
//in
printf("Enter the number of words for delete:\n>");
scanf("%u",&N);
// printf("\n\n");
//out
del_N(N);
printf("\n\n");
system("PAUSE");
return 0;
}