Click here to Skip to main content
15,895,256 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: WS_TABSTOP Pin
jkirkerx9-Dec-11 20:18
professionaljkirkerx9-Dec-11 20:18 
GeneralRe: WS_TABSTOP Pin
Stephen Hewitt9-Dec-11 21:22
Stephen Hewitt9-Dec-11 21:22 
AnswerIt works, now but how to detect shift tab << Pin
jkirkerx8-Dec-11 12:40
professionaljkirkerx8-Dec-11 12:40 
GeneralRe: It works, now but how to detect shift tab << Pin
Graham Breach8-Dec-11 13:06
Graham Breach8-Dec-11 13:06 
GeneralRoom for improvement let me know. Pin
jkirkerx8-Dec-11 13:16
professionaljkirkerx8-Dec-11 13:16 
QuestionParsing in C Pin
Software20077-Dec-11 6:55
Software20077-Dec-11 6:55 
AnswerRe: Parsing in C Pin
Albert Holguin7-Dec-11 7:23
professionalAlbert Holguin7-Dec-11 7:23 
AnswerRe: Parsing in C Pin
Chris Losinger7-Dec-11 8:10
professionalChris Losinger7-Dec-11 8:10 
so, is it "n(nodename)" that signals the end of a 'node' and "d(whatever)" for the start?

i always find state-machines the easiest way to do simple parsing.

off the top of my head...
typedef struct item_t
{
   char d[100];
   char b[100];
   char n[100];
} item;

const char *consume_between_parens(const char *p, char *out)
{
   if (*p!='(') return NULL; // error

   p++;
   while (*p)
   {
       if (p==')') // done
       {  
           p++;
           break;
       }
       *out = *p; // copy
       out++; p++; // next
   }

   return p;
}

void parse(const char *p, itemArray array ... some array thing)
{
  enum {wantD, wantB, wantN} state = wantD;

  item * curItem = null;

  while (*p)
  {
     switch (state)
     {
         case wantD:  // we need a 'd'
            if (*p=='d')
            {
                curItem = malloc(sizeof(item));
                p = consume_between_parens(p, curItem->d);
                state = wantB;
            }
            else error
            break;
         case wantB:  // we need a 'b'
            if (*p=='b')
            {
                p = consume_between_parens(p, curItem->b);
                state = wantN;
            }
            else error
         case wantN:  // we need an 'n'
            if (*p=='n')
            {
                p = consume_between_parens(p, curItem->n);
                addToArray(array, curItem);
                state = wantD;
            }
            else error
            break;
         default: 
            error;
     }
     p++;
  }
while 


GeneralRe: Parsing in C Pin
Software20077-Dec-11 9:54
Software20077-Dec-11 9:54 
QuestionRe: Parsing in C Pin
David Crow7-Dec-11 9:27
David Crow7-Dec-11 9:27 
AnswerRe: Parsing in C Pin
Software200710-Dec-11 13:28
Software200710-Dec-11 13:28 
AnswerRe: Parsing in C Pin
Software200712-Dec-11 5:52
Software200712-Dec-11 5:52 
AnswerRe: Parsing in C Pin
David Crow12-Dec-11 7:15
David Crow12-Dec-11 7:15 
GeneralRe: Parsing in C Pin
Software200712-Dec-11 7:32
Software200712-Dec-11 7:32 
SuggestionRe: Parsing in C Pin
David Crow12-Dec-11 8:34
David Crow12-Dec-11 8:34 
GeneralRe: Parsing in C Pin
Software200712-Dec-11 9:36
Software200712-Dec-11 9:36 
QuestionDouble value precision Pin
mutpan6-Dec-11 18:54
mutpan6-Dec-11 18:54 
AnswerRe: Double value precision Pin
Chandrasekharan P6-Dec-11 19:27
Chandrasekharan P6-Dec-11 19:27 
GeneralRe: Double value precision Pin
mutpan6-Dec-11 19:35
mutpan6-Dec-11 19:35 
GeneralRe: Double value precision Pin
Chandrasekharan P6-Dec-11 20:33
Chandrasekharan P6-Dec-11 20:33 
AnswerRe: Double value precision Pin
CPallini6-Dec-11 22:13
mveCPallini6-Dec-11 22:13 
GeneralRe: Double value precision Pin
Albert Holguin7-Dec-11 3:24
professionalAlbert Holguin7-Dec-11 3:24 
AnswerRe: Double value precision Pin
tssutha036-Dec-11 22:30
tssutha036-Dec-11 22:30 
AnswerRe: Double value precision Pin
Chuck O'Toole7-Dec-11 5:03
Chuck O'Toole7-Dec-11 5:03 
AnswerRe: Double value precision Pin
JackDingler9-Dec-11 9:30
JackDingler9-Dec-11 9:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.