Why is this code only evaluating the first character of datatest?. I need it to test if the string contains only alphanumeric letter and whitespace characters and store it in records.data. rCount is a count of the records. It all works as intended expect the islanum and isspace function which is only evaluating the first character in the string and storing it. The way is works is good, except i want it to do it for the whole string not just the first character. If the data contains anything other than alphanumeric characters or whitespace i will store it elsewhere
for (i=0; i<=datalength; i++)
{
if ((sourceint < 1025 && sourceint >0)&&
(portint <1025 && portint >0) &&
(typeint < 11 && typeint >=0) &&
(destinationint <1025 && destinationint >0) &&
(datalength < 51) &&
(isalnum(datatest[i]) || isspace(datatest[i])))
{
records[*rCount].destination = destinationint;
records[*rCount].type = typeint;
records[*rCount].port = portint;
records[*rCount].source = sourceint;
for (i=0; i<=datalength; i++)
{
records[*rCount].data[i] = datatest[i];
records[*rCount].data[i+1] = '\0';
}
printf("VALID DATA FROM STRUCT - %i - %i - %i - %i - %s\n", records[*rCount].source, records[*rCount].destination, records[*rCount].type, records[*rCount].port, records[*rCount].data);
}
}