Click here to Skip to main content
12,951,971 members (64,329 online)
Rate this:
Please Sign up or sign in to vote.
See more:
i have a data like this

	 char bufget[]="RE000022701500Ì200 0.00 6.113.937";
    char preSendBuf[138];
    int ptr=0;
    int q=strlen(bufget);
    for(int i=0;i<q;i++)
	//i know here we should decrement *digits index again to zero but how	
	return 0;

actually data that i should get in
preSendBuf should be "RE000022701500200 0.00 6.113.937"
Posted 8-Nov-12 5:25am
Member 9562996 9-Nov-12 4:27am
What is digits here?
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

It appears that someone has deleted my comments from yesterday on this issue. I have suggested to you a number of times how to process these data records, by using the information provided by the manufacturer. Each record has a predefined structure allowing you to access individual fields and validate them against the data specification. Make use of that information rather than continually trying to invent complicated parsing rules and making your programs more difficult that they need to be.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

You have omitted that information, but digits (initially) appears to be a 0-terminated array of "acceptable" characters.

You are abusing the symbol digits for iterating over that set of characters, thereby losing the reference to the start of this array. What you should do instead is introduce a helper variable for that particular purpose (i. e. iterating), e. g.:

for (int i = 0; i < q; ++i) {
   char* pdigits = digits;
   while (*pdigits) {
      if (budget[i] == *pdigits++) {
         // ...
Richard MacCutchan 9-Nov-12 6:11am
OP has a document which spells out the exact structure of these records (referred to in a far earlier question) but will not or cannot use it. Also seems to have only rudimentary knowledge of C/C++ and yet is trying to develop a system for collecting live information from patient sensor devices in a hospital.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,239
CHill60 3,490
Maciej Los 3,083
Jochen Arndt 1,975
ppolymorphe 1,880

Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 9 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100