extract characters to '.'
I am trying to write a function to extract a number of characters in a file name given to a function up to the '.' character.
My function is below. I am trying to copy the characters pointed to by the fName pointer to a data member dataSetName up to the '.' operator reached in the fName pointer.
For some reason I get no output for the dataSetName. Why is this not working?
void Layer::setDataSetName(char * fName)
int result; //result buffer
//if it is a featureclass
if(result = (strcmp(layerType, "featureclass") == 0))
int count = 0; //holds count of characters in argument
//count num of characters up to the '.' character
for(int i = 0; fName[i] != '.'; i++)
cout << "count is " << count << endl;
//allocate space for the dataSetName
dataSetName = new char[count + 1];
//copy the characters up the '.' character
for(; *fName != '.'; fName++, dataSetName++)
*dataSetName = *fName;
cout << "*dataSetName = " << *dataSetName << " *fName = " << *fName << endl;
//place a null character after the last character
*dataSetName = '\0';
} //end if a featureclass
//else it is an image
//keep the extension
dataSetName = new char[strlen(fName) + 1];
} //end else it is an image
} //end setDataSetName