a code to filter full path

This is a discussion on a code to filter full path within the C++ Programming forums, part of the General Programming Boards category; Code: char *path_filter(char *path_exe) { // char path_buffer[MAX_PATH]; char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; char fname[_MAX_FNAME]; char ext[_MAX_EXT]; _splitpath(path_exe ,drive, dir , ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    114

    a code to filter full path

    Code:
    char *path_filter(char *path_exe)
    {
    //	char path_buffer[MAX_PATH]; 
    	char drive[_MAX_DRIVE];
    	char dir[_MAX_DIR];
    	char fname[_MAX_FNAME];
    	char ext[_MAX_EXT];
    
    	_splitpath(path_exe ,drive, dir , fname , ext  );
    	return drive dir fname;
    }
    i am trying to write a code to filter a full path to a exe file
    for example,

    "C:\\Program Files\\Webzen\\mu\\mu.exe"

    after filtering by function returns

    "C:\\Program Files\\Webzen\\mu"

    the above is what i have tried to write but doesnt work

    anything wrong?
    how should i return the function?
    return drive dir fname definately doesnt work
    Last edited by hanhao; 03-07-2004 at 05:08 AM.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,489
    Yeah, please edit your post to put the [code][/code] tags around your code
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    114

    returning different char types

    Code:
    char drive[_MAX_DRIVE];
    char dir[_MAX_DIR];
    char fname[_MAX_FNAME];
    char ext[_MAX_EXT];
    
    char *fx()
    {
    .........
    return drive, dir,fname;
    
    }
    let's say
    drive = c:\
    dir = a_dir\
    fname = abc.exe

    how do i make it return "c:\a_dir\abc.exe"???

    the above code doesnt cut it

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,489
    Something like
    Code:
    char *path_filter(char *path_exe, char *result)
    {
    	char drive[_MAX_DRIVE];
    	char dir[_MAX_DIR];
    	char fname[_MAX_FNAME];
    	char ext[_MAX_EXT];
    
    	_splitpath(path_exe ,drive, dir , fname , ext  );
    	strcpy( result, drive );
    	strcat( result, dir );
    	strcat( result, fname );
    	return result;
    }
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Finding object code
    By kidburla in forum C Programming
    Replies: 3
    Last Post: 11-29-2005, 12:09 PM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  3. re:array of notation (full code)
    By lcpongkl in forum C Programming
    Replies: 2
    Last Post: 04-08-2003, 06:15 AM
  4. True ASM vs. Fake ASM ????
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 04-02-2003, 03:28 AM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM

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