G
Grumble
Mabden said:Did you grow a sensual humor?
"sensual humor" is that another old-timer joke?
Mabden said:Did you grow a sensual humor?
In said:I don't know about any standard C answer to the stated problem,
but your example might imply UNIX pathname syntax (although
also acceptend on Windoze, though not on command line).
So even
standard C answer (e.g. strrchr(), as suggested) may be platform specific.
If you are on UNIX, there should be basename(3C). For details
see e.g. here:
http://docs.sun.com/db/doc/805-3175/6j31emn1l?a=view#basename-3c-indx-1
My apologies to the group for an OT answer. But in this case I consider
it worth giving. It's not portable, but neither are some others. I've
already
forgotten what path looked like on VAX.
Original problem was to extract
file name from the full path name, not to find last '/'.
nobody said:I don't know about any standard C answer to the stated
problem,
but your example might imply UNIX pathname syntax
(although
also acceptend on Windoze, though not on command line).
So even
standard C answer (e.g. strrchr(), as suggested) may be
platform specific. If you are on UNIX, there should be
basename(3C). For details
see e.g. here:
http://docs.sun.com/db/doc/805-3175/6j31emn1l?a=view#basename-3c-indx-1
My apologies to the group for an OT answer. But in this
case I consider it worth giving. It's not portable, but
neither are some others. I've already
forgotten what path looked like on VAX. Original problem
was to extract file name from the full path name, not to
find last '/'.
Chris McDonald said:Is there something inherently wrong with using standard functions, here,
or is this just a macho contest?
Mabden said:Hey, Martin! I thought you killfiled me over some comedy I posted
once! Did you grow a sensual humor?
Chris McDonald said:Is there something inherently wrong with using standard functions,
here, or is this just a macho contest?
Grumble said:"sensual humor" is that another old-timer joke?
Dan Pop said:In <[email protected]> "Mabden" off string.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
What makes you think that strrchr() doesn't work exactly as you have
described above? All the generic C implementations of strrchr() I am
familiar with do a single scan, until they find the null character and
"remember" the last address of the target character.
CBFalconer said:while the complex single scan is something like:
pp = NULL; p = ptr;
while (*p) {
if ('/' == *p) pp = p;
p++;
}
kal said:The following may also work, if somewhat differently.
pp = p = ptr;
while (*p) {
if ('/' == *(p++)) pp = p;
}
CBFalconer said:It will have a one-off error.
Chuck, beating macho breast loudly.
Dan Pop said:In <[email protected]> "nobody"
Even on command line, on modern Windows versions. It's only the good old
COMMAND.COM (R.I.P.) that had a problem with them.
If you really think that, you're reading impaired. The description of the
original problem is still included at the top of the article and it seems
to have everything to do with finding the last '/' character.
In said:I needed a function to take a unix pathname like "/home/foo/dir/subdir/" and
create any necessary directories that didn't already exist in the path. For
example /home/foo may exist, but dir and dir/subdir might not. Here's the
code I came up with: (only non-standard functions here are mkdir() and
direxists() and they're not really part of the text processing algorithm).
In said:Maybe that depends on definition of "modern". It doesn't work on NT 4.0
and I believe neither on 2K (don't have one on hand):
Microsoft(R) Windows NT(TM)
(C) Copyright 1985-1996 Microsoft Corp.
C:\users>cd \temp
C:\TEMP>cd /users
The syntax of the command is incorrect.
C:\TEMP>cd \users
C:\users>
I *might* be reading impaired, but I still didn't get it why you my think so
based on OP and my assertions. Description of the problem seems to to have
everything to do with extracting file name from path name. Finding of last
'/'
is part of one of the solutions, but not a problem definition itself.
Hey u can always use strrchr function supplied with string.h
library...if u r using Microsoft C/Turbo C
kal said:(e-mail address removed) (Shuvodeep) wrote in message
1. My understanding is that "top posting" is bad manners here.
If you are using Linux or Unix, there should be a function availableJoe said:If I have a character array with "/some/file/directory/file_name", are there
any functions / libraries that I could use to separate the directory
("some/file/directory") from the file name ("file_name").
I looked at sscanf(), but that didn't seem to do what I wanted.
Joe said:If I have a character array with
"/some/file/directory/file_name", are there
any functions / libraries that I could use to separate the directory
("some/file/directory") from the file name ("file_name").
I looked at sscanf(), but that didn't seem to do what I wanted.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.