www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/04/02:24:53

From: "Cephaler" <scully AT ix DOT netcom DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Command Parser
Date: 4 Apr 1997 02:27:53 GMT
Organization: Netcom
Lines: 31
Message-ID: <01bc409f$afbb59c0$97c3b8cd@scully>
NNTP-Posting-Host: wbg-va4-23.ix.netcom.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

  This isn't much a DJGPP question, rather a general C question. Actually,
it is, because the program this question was produced from is an IDE I am
making for djgpp. Anyway, it will be a command-driven IDE, a simple, easy
to use IDE designed for the newbie DJGPPer. Anyway, I need to know, how
would one go about making a parser to seperate one big string(what the user
typed in) into little chunks, kind of like how command-line parameters are
organized. I've already written a command-line parameter parser, so I would
be able to design it that way. I've tried different methods, but I'm either
doing something wrong, or just going about it the wrong way. So basically,
what I need is a simple parser, one that would work with gets(input) (input
= char *input) or scanf("%s",input) and divide each "chunk" of characters
into seperate strings and put them all into one big array... kind of
like....

Prog output: Enter a command: _
User Input: /showfilestats math.c

then, after that, the program parses the user input and puts it into char
*UserCommand[10] like this:

UserCommand[0] = /showfilestats
UserCommand[1] = math.c

Then, I can figure the rest out myself :) But as of now, I have no idea how
to do something like that, I have never programmed a command-driven
program. Hmm, if it's possible, could you please mail me some sample code?
I'm an extremely fast visual learner, and I check my mail more often that
news. Thanks in advance

- Cephaler -

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019