Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

COMMAND LINE ARGUMENTS

Name: Anonymous 2007-08-04 20:01 ID:emGOLTl7

Why an array of strings? Why not just a single string? You're going to have to do some parsing anyway.

Name: Anonymous 2007-08-04 20:06 ID:Heaven

Voncenience.

Name: Anonymous 2007-08-04 20:10 ID:xH+oEF2Q

>>1 is right. Every programmer should spend half of his time reinventing the wheel.

Name: Anonymous 2007-08-04 20:23 ID:AkU5l+5w

Command line arguments are so like ten years ago. They're inconvenient, but so what? If an array of C-style strings are the most complicated thing in your program, you have a trivial application.

Name: Anonymous 2007-08-04 20:37 ID:emGOLTl7

>>3
No, dumbass, I meant parsing with a library.

Think about it, if it was a single string, people would be more inclined to use something like getopt, instead of hacking up a shitty parser by themselves. Think about how much better life would be.

Name: Anonymous 2007-08-04 21:01 ID:cyqSUkgh

>>5
Has a point.. kinda. The thing is that sometimes (mosttimes?) array of strings is all I need, forcing everyone for every quick hack to use some heavy library just doesn't sound good to me.

Name: Anonymous 2007-08-04 21:04 ID:zKW2ihF1

>>5
What? getopt operates on an array of strings, not a single string. Maybe you're confusing it with something else?

Name: Anonymous 2007-08-04 21:07 ID:/uAAUsjz

>>7

Key parts highlighted for dumb readers:

I meant parsing with a library.

Think about it, if it was a single string, people would be more inclined to use something like getopt, instead of hacking up a shitty parser by themselves.

Name: Anonymous 2007-08-04 21:13 ID:c4bQRQTL

>>7
hm yaeh thats a good point, if it was a single string getopt would be useless. I guess the OP just had a brainfart.

Name: Anonymous 2007-08-04 23:12 ID:Heaven

>>8
I think you're not understanding correctly, so I will iterate through the highlights of this thread.

>>1 asserts that a single string, instead of an argv is better, because ``[you have to] parse them anyway''

>>3 proceeds to chide >>1 for his ignorance. The rather correct assertion made by >>3 is that it's pointless having to recreate a parser when it's done automatically by the c runtime (ie. before main gets called)

Here is where the confusion is introduced. >>5 (which is the OP) claims that there will be no reinvention of the wheel, so to speak, as one could do ``parsing with a library.'' The next sentence here is:
``Think about it, if it was a single string, people would be more inclined to use something like getopt''
This statement does not make sense. If it were a single string, why would people be more inclined to use getopt? getopt requires not a single string, but an array of strings (ie. argv), representing command line options. In fact, getopt was designed with argc/argv in mind.

tl;dr:
>>1,5 has never used getopt in her life. They are most likely a troll, and as such, it is highly recommende to proceed with sage.

Name: Anonymous 2007-08-04 23:45 ID:Heaven

>>10
No, YOU don't understand. >>5 is saying we would use something like getopt. Admittedly, it was a shitty example. Commencing sage.

Name: Anonymous 2007-08-05 0:20 ID:+Z7VcJyi

This was introduces in year 19XX, when people were thinking about making thinks work, not achieving satori. you lisp toads disgust me.

Name: Anonymous 2007-08-05 0:22 ID:Heaven

>>12
Failed sage

Name: Anonymous 2007-08-05 5:29 ID:Heaven

Why an array of strings? Why not just a single string? You're going to have to do some parsing anyway.

An array of strings is an array of characters.
fucking sage.

Name: Anonymous 2007-08-05 8:37 ID:zppIgQaE

I don't know about you guys, but my argument handling looks something like:

for (int i = 0; i < c; i++)
{
    if (strmp(argv[i], "-i") == 0)
    {
        // do something for -i
    }
    else if (strmp(argv[i], "-x") == 0)
    {
        // do something for -x
    }
    else
    {
        // do something with the single arg
        // normally filename
    }
}

Parsing is something totally different and I know I build compilers for a living. ;-)

Name: Anonymous 2007-08-05 8:50 ID:sMAAFry3

>>11
you should really read ``man getopt'' before making this kind of statement

>>15
building computers is not parsing

Name: Anonymous 2007-08-05 9:02 ID:+Z7VcJyi

Also: man exec

Name: Anonymous 2007-08-05 9:10 ID:Heaven

Sage.

Name: Anonymous 2007-08-05 23:42 ID:0bdWk/I2

>>16
he said COMPILERS you fucking retard

Name: Anonymous 2009-03-06 7:41

getopt scroll down where   it says BUGS.

Don't change these.
Name: Email:
Entire Thread Thread List