1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
/* by Peter Pentchev, 2008, public domain. */
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
const char * const utf8bom = "\xef\xbb\xbf";
static void usage(const char *);
static void outendl(const string &);
static void
usage(const char * const prog)
{
cerr << "usage: " << prog << endl;
exit(1);
}
static void
outendl(const string &s)
{
cout << s;
if (!cin.eof())
cout << endl;
}
int
main(const int argc, const char * const argv[])
{
string s;
if (argc > 1)
usage(argv[0]);
/* Empty? */
if (!getline(cin, s))
return 0;
/* First line... */
if (!s.substr(0, 3).compare(utf8bom))
s = s.substr(3);
outendl(s);
/* ...and the rest. */
while (getline(cin, s))
outendl(s);
}
|