Question in Char Array

For the discussion of Arduino related topics.

Moderator: phalanx

Post Reply
brian25
Posts: 15
Joined: Sat Jun 22, 2013 5:22 am

Question in Char Array

Post by brian25 » Wed Oct 09, 2013 8:49 am

i'm using gsm lib and i want to separate the content of smsbuffer. ex Hello World then i will disregard the Hello and i will only get the World and store in Another byte/char array. tnx

KeithB
Posts: 287
Joined: Wed Oct 27, 2010 1:38 pm

Re: Question in Char Array

Post by KeithB » Wed Oct 09, 2013 8:57 am

look at strtok()

brian25
Posts: 15
Joined: Sat Jun 22, 2013 5:22 am

Re: Question in Char Array

Post by brian25 » Fri Oct 11, 2013 10:30 pm

i used arduino lib

Regexp.h

Code: Select all

MatchState ms;
  char * str = smsbuffer;
  ms.Target (str);
  
  unsigned int index = 0;
  char buf [100];
  
  while (true)
  {
  char result = ms.Match ("(%a+)" "(%-?%d+)", index);
  
   if (result == REGEXP_MATCHED){
     for (int j = 0; j < ms.level; j++);
     gsm.WritePhoneNumber(result[j],(%-?%d+);
     index = ms.MatchStart + ms.MatchLength;
   }
   else 
     break;
  }
}

can you help how to correct this one.. tnx

mlu
Posts: 221
Joined: Wed Jun 21, 2006 1:43 pm
Location: Gothenburg, Sweden

Re: Question in Char Array

Post by mlu » Tue Oct 15, 2013 10:40 am

There is a semicolon to much in the for statement:

Code: Select all

     for (int j = 0; j < ms.level; j++);
should be

Code: Select all

     for (int j = 0; j < ms.level; j++)
I think the compiler is complaining about this because with the extra semi colon, j
will not be defined on the next line.
Also the gsm.WritePhoneNumber looks wrong, what is the second argument ?

Post Reply