I can normally extract the data of array as:
#include <stdio.h>
int main()
{
char str[100] = "The quick brown fox jumps over the lazy dog";
char *c = (str + 29);
printf("%s\n", c);
return 0;
}
But if I have to extract data from the entire unsorted and n-sized array where n value may be more than 70 as like:
unsigned char buffer[n] = "00,00,00,11,30,45.00,a,1.1,b,d,16,ABC,98.0";
unsigned char buffer1[n] = "A,3,22,18,21,06,03,09,24,15,,,,,2.5,1.6,1.9*3E";
How can I extract some specific data like 45.00 from this unsorted array?
45.00is in the data, why do you need to extract it? If you mean "how can I find out if45.00is in the data", then maybestrstr()is what you're after. Do you have to worry about a comma before the string (to avoid picking up"12.00,145.00,29.00"or the comma after it (to avoid picking up"12.00,45.00")? What exactly are you trying to do?strchr()to find','frombuffer[].45.00surrounded by commas, or at the start of the string followed by a comma, at the end of the string preceded by a comma? This avoids picking up145.00, or45.001. And you won't be trying to find strings that start or end with comments? And you won't be wanting to find45even though45.00and45are the same mathematically (even though they're different strings).buffer1where there may not be data inside comma or not.