It may help if you gave us an example of what the resultant query/data set looked like and while your at it, could you show us the definition of test.
gerard4143
Nearly a Posting Maven
2,272 posts since Jan 2008
Reputation Points: 512
Solved Threads: 387
Try something like below:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
/*our dummy data set*/
#define DATASIZE 100
#define DATSET "ThiS iS ThE mESSaGE 23h to sENd ov4er th4re\n"
int main(int argc, char**argv)
{
int i = 0;
char ch[DATASIZE];
char *pstr = NULL;
strncpy(ch, DATSET, DATASIZE);
for (i = 0; i < strlen(ch); ++i)
ch[i] = tolower(ch[i]);
pstr = strtok(ch, " ");
fprintf(stdout, "%s\n", pstr);
do
{
pstr = strtok('\0', " ");
if (pstr) fprintf(stdout, "%s\n", pstr);
}
while (pstr);
exit(EXIT_SUCCESS);
}
I greatly simplified what you posted...I hope this will do..It parses the data set but doesn't check for numbers.
gerard4143
Nearly a Posting Maven
2,272 posts since Jan 2008
Reputation Points: 512
Solved Threads: 387
This is an idiom to avoid ( * ):
for (i = 0; i < strlen(ch); ++i)
This is more confusing than it ought to be:
pstr = strtok('\0', " ");
You mean NULL. Use NULL.
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314