Thread: character substring

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    26

    character substring

    Is there something out there that would allow me to take a substring of a character not a string? My character is a path name and I need to take the substring of the drive letter (i.e. C:\) only!

  2. #2
    Registered User
    Join Date
    Feb 2002
    Posts
    26
    my post was lost....any suggestions!!!!!!

  3. #3
    Sayeh
    Guest
    Gee, that sounds like a routine you could write yourself!

    I mean, golly gosh! since the string you have is just an array of characters, at the very least you could smatter together a routine like this (not how I would do it)--

    Code:
    int main(void);
    void getdrivestring(char*,char*);
    
    
    int main(void)
       {
       char driveString[4];                       /* just enough to hold device letter */
       char path[] = "C:/Windows/System";
    
       getdrivestring(path,driveString);  /* parse out the letter */
       
       return(0);
       }
    
    void getdrivestring(char *a,char *b)
       {
       int  i;
    
       for(i=0;i<3;i++)
          b[i] = a[i];                                  /* copy first 3 letters */
    
       b[3] = 0x00;                                 /* length terminating byte */
       }

    seems rather brute-force, yet it would do the trick, eh?

  4. #4
    Registered User
    Join Date
    Feb 2002
    Posts
    26
    PROBLEMS ALL RESOLVED...THANKS FOR SUGGESTIONS!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 11
    Last Post: 10-07-2008, 06:19 PM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  4. character substring
    By Shawty in forum C++ Programming
    Replies: 2
    Last Post: 11-14-2002, 09:57 PM
  5. UNICODE and GET_STATE
    By Registered in forum C++ Programming
    Replies: 1
    Last Post: 07-15-2002, 03:23 PM