c : remove dup line
char buf[163840];
char keep_line[163840];
int _tmain(int argc, _TCHAR* argv[])
{
/*
printf("\nargc=%d",argc);
if(argc>1)
{
_tprintf(L"\nargv[1]=%s",argv[1]);
}
printf("\n");
*/
keep_line[0]=0;
char *p=NULL;
while(1) {
p=gets(buf);
if(p==NULL)
break;
if(p!=buf) {
printf("\n buf != p ??\n");
break;
}
int len=strlen(p);
if(len==0)
continue;
int diff=strcmp(p,keep_line);
if( ! diff ) { // dup line find
// printf("\n--- %s",p);
continue;
}
strcpy(keep_line,p);
printf("\n%s ",p);
// printf("\n%d %s",len,p);
}
printf("\n");
return 0;
}
char keep_line[163840];
int _tmain(int argc, _TCHAR* argv[])
{
/*
printf("\nargc=%d",argc);
if(argc>1)
{
_tprintf(L"\nargv[1]=%s",argv[1]);
}
printf("\n");
*/
keep_line[0]=0;
char *p=NULL;
while(1) {
p=gets(buf);
if(p==NULL)
break;
if(p!=buf) {
printf("\n buf != p ??\n");
break;
}
int len=strlen(p);
if(len==0)
continue;
int diff=strcmp(p,keep_line);
if( ! diff ) { // dup line find
// printf("\n--- %s",p);
continue;
}
strcpy(keep_line,p);
printf("\n%s ",p);
// printf("\n%d %s",len,p);
}
printf("\n");
return 0;
}
標籤: c, remove duplicate line