bladox.com Forum Index bladox.com
Turbo SIM Toolkit Adapter Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Maybe this is a stupid question...

 
Post new topic   Reply to topic    bladox.com Forum Index -> Development
View previous topic :: View next topic  
Author Message
bywuu



Joined: 04 Aug 2011
Posts: 29

PostPosted: Tue Jan 31, 2012 8:29 am    Post subject: Maybe this is a stupid question... Reply with quote

Hi,
Now I want to know the position of the second comma in my string ,let's say the string is:"123456789,546321874541321,111",if I write this:
Code:

u8 endPos = 10;//the first comma position is set
u8 p[] = "123456789,546321874541321,111";
     while(p[endPos]!=','){
         endPos++;
     }
     memcpy(phoneNum,p+10,endPos-10);

it is fine,but if I write this:
Code:

u8 endPos = 10;//the first comma position is set
u8 PROGMEM myProductStr[]="123456789,546321874541321,111";
while(myProductStr[endPos]!=','){
         endPos++;
     }
     memcpy(phoneNum,myProductStr+10,endPos-10);


it just hang...even if I changed it into:
Code:

while(rb(myProductStr[endPos])!=','){

it still not work...I know it must be something about the PROGMEM.
So what is the correct methord?How to do it?
I now using a stupid way:
Code:

u8 * p = malloc(1);
    memcpy(p,myProductStr+endPos,1);
    p[1]=0;
    while(p[0]!=',')
        {
            endPos++;
        memcpy(p,myProductStr+endPos,1);
            p[1]=0;
        }
    free(p);


Do you have any better idea?
Thanks
Back to top
View user's profile Send private message
pz



Joined: 12 Mar 2004
Posts: 1161

PostPosted: Wed Feb 01, 2012 10:54 am    Post subject: Reply with quote

Code:


u8 PROGMEM myProductStr[]="123456789,546321874541321,111";

void somefnc()
{
u8 endPos = 10;//the first comma position is set

while(rb(myProductStr+endPos)!=','){
         endPos++;
     }
....
}


So have the myProductStr[] out of call and rb() is a must.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    bladox.com Forum Index -> Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group