# include <iostream.h> # include <fstream.h> # include <string.h> # include <stdlib.h> # include <conio.h> int main( ) { clrscr( ); fstream File("CP-27.txt",ios::in|ios::nocreate); if(!File) { cout<<"\n Unable to open the input file."<<endl; cout<<"\n Press any key to exit."; getch( ); exit(EXIT_FAILURE); } char Delimiter[15]={NULL}; char String[1000]={NULL}; char Temp[100]={NULL}; int flag=0; File.getline(Delimiter,10); do { strset(Temp,NULL); File.getline(Temp,100); strcat(String,Temp); if(File.eof( )) flag=1; while(strstr(String,Delimiter)!=NULL) { char* Ptr=strstr(String,Delimiter); strset(Temp,NULL); for(int i=(strlen(String)-strlen(Ptr)+strlen(Delimiter)), j=0;i<strlen(String);i++,j++) Temp[j]=String[i]; for(int k=0;k<(strlen(String)-strlen(Ptr));k++) cout<<String[k]; cout<<endl; strset(String,NULL); strcpy(String,Temp); } if(flag) { cout<<String; break; } else { int length=strlen(String); for(int i=0;i<(length-10);i++) cout<<String[i]; strset(Temp,NULL); for(int j=0;j<10;j++,i++) Temp[j]=String[i]; strset(String,NULL); strcpy(String,Temp); } } while(1); File.close( ); getch( ); return 0;
}
No comments:
Post a Comment