Hi,
A specific set of range
<10,20>
<20,30>
<30,40>
<40,50>
i have series of numbers in a buffer;
say.. 11 14 19 23 28 45 49 is present in char* noInBuff;
Every time if the number falls in specific range for the first time then i have to replace it with a string, and if the next too falls in the same range then i do nothing.. same things continues. and simultaneously i have to concatenate in an a char array.
so at the end i will receiving the output as,
output = [eleven 14 19 twentythree 28 fortyfive 49]
char* temp = strtok(noInBuff, " ")
while(temp != null)
{
if((noInBuf >= 10) && (noInBuff <20) && (count1==0))
{
replace that no. with string;
strcat(strname, "string1");
count1++;
}
else if ((noInBuf >= 20) && (noInBuff <30) && (count2==0))
{
replace that no. with string,
concatenate in another char array;
count2++;
}
else if ((noInBuf >= 30) && (noInBuff <40) && (count3==0))
{
replace that no. with string,
concatenate in another char array;
count3++;
}
else if ((noInBuf >= 40) && (noInBuff <50) && (count4==0))
{
replace that no. with string,
concatenate in another char array;
count4++;
}
}
count1=count2=count3=count4=0;
so for that i had the above code which will work for the above scenario, but what if in the future i have numbers going beyond 60, 70 then i have to again write the code for the same. what exactly i wanna know is that Is there any other way to make it generic, just by inserting range in the text file, so i do not have to touch the code.