I have a C++ snippet:
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
char s[2048];
while (fgets(s, sizeof(s), stdin))
{
char *pos = strpbrk(s, ">\r\n");
if (pos != 0)
{
char *end = strrchr( pos, '<' );
if ( end )
*end = '\0';
fputs(pos+1, stdout);
}
return 0;
}
}
Although when trimming a text file using it, it works with only 1 line e.g. it trims 1 line only.
If I try to trim multiple lines e.g. file with 30 lines in it, it only trims one line still. I am pretty confused, any help would be appreciated.
Example text file:
report2011510222820.html: <td width="60%" bgcolor="#ffffff" class="tablebody" valign="top">C:\Users\Admin\mon.bat</td>
report2011510222820.html: <td width="60%" bgcolor="#ffffff" class="tablebody" valign="top">C:\test123.bat</td>
Output:
C:\Users\Admin\mon.bat
Expected Output:
C:\Users\Admin\mon.bat
C:\test123.bat
[c], and ask about C. If you pretend it is C++, then you'll mainly get a lot of answers telling you how your code should be rewritten in C++ - jalf