-
string cluster part 2
Ok, I could use some more help on my dos 8.3 filename format problem. Thus far I've gotten the first half of the filename to work thanks to those that helped on the last post.
char fileName[13];
char filename[13]; // will work on this later
int index = 0;
int count1 = 0;
for(count1 = 0; count1 < fileName[count1]; count1++)
{
strxfrm(filename, fileName, count1)
if(fileName == '.')
{
index = strstr(fileName, ".") - fileName;
if(index > 8)
{
printf(filename entry wrong);
exit(1);
}
break; // got my filename first half seperated at the .
}
}
This portion works now. However, what I can't figure out is how to advance the fileName past the period to catch the second part of the filename. Nothing is working. I also need the second half for error control if the user types in something like my.program. Since it is less than the array it will still be processed though the 8.3 format has been violated. Any ideas?
TIA
-
Assuming there are only ever a maximum of three digits past the '.', simply count back 4 spaces from the end, check to see if it is a '.', if not, advance one, repeat.
int x;
x=strlen(string)-4;
Quzah.
-
I've tried that too, but it doesn't do what I need when I go to copy the stuff after the . to a array variable. The program will make four tests for the filename entered.
test 1 - file length < 13 done with strlen
test 2 - test for the period done with strstr(filename, ".")
test 3 - first part of file name <= 8 (done with index)
test 4 - second half of file <= 3 (can't get this to work)
That is the part that I need. I've got to strip off the filename up to and including the "." and then copy the rest into an array variable that is later converted to a pointer. If I use the filename[count] method again, it will print garbage for the last three digits
Any other ideas?
Thanks for the reply.