--- a/numerierung.c
+++ b/numerierung.c
@@ -10,13 +10,13 @@
void usage (char *cmd)
{
- printf ("Usage: %s [-h] [-t] [-v] [file]\n", cmd);
+ printf ("Usage: %s [-h|-p] [<file>]\n", cmd);
exit (0);
}
int main (int argc, char **argv)
{
- char buffer[81];
+ char buffer[240];
int counter = 0;
@@ -24,8 +24,12 @@
int c, pure = 0;
- while ((c = getopt (argc, argv, "hp")) != -1) {
- printf ("Zeichen: %c\n", c);
+ struct option options[] = {
+ {"help", 0, 0, 'h'},
+ {"pure", 0, 0, 'p'},
+ };
+
+ while ((c = getopt_long_only (argc, argv, "hp", options, NULL)) != -1) {
switch (c) {
case 'h':
usage (argv[0]);
@@ -36,7 +40,6 @@
default:
printf ("Unknown Parameter: %s\n", argv[optind]);
}
- printf ("GETOPT: %d : %s\n", optind, argv[optind]);
}
if (optind == argc)
@@ -51,7 +54,7 @@
*buffer = 0;
- while (fgets (buffer, 80, f) != NULL) {
+ while (fgets (buffer, sizeof (buffer), f) != NULL) {
if (!pure)
printf ("%4.4d: %s", counter++, buffer);
else