string cluster part 2

This is a discussion on string cluster part 2 within the C Programming forums, part of the General Programming Boards category; Ok, I could use some more help on my dos 8.3 filename format problem. Thus far I've gotten the first ...

  1. #1
    Casual Visitor
    Join Date
    Oct 2001
    Posts
    350

    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
    I haven't used a compiler in ages, so please be gentle as I try to reacclimate myself. :P

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    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.
    Hope is the first step on the road to disappointment.

  3. #3
    Casual Visitor
    Join Date
    Oct 2001
    Posts
    350
    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.
    I haven't used a compiler in ages, so please be gentle as I try to reacclimate myself. :P

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 05:30 PM
  2. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  3. Program using classes - keeps crashing
    By webren in forum C++ Programming
    Replies: 4
    Last Post: 09-16-2005, 04:58 PM
  4. problems with overloaded '+' again
    By Brain Cell in forum C++ Programming
    Replies: 9
    Last Post: 04-14-2005, 06:13 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21