Advertisement

03.10.2008 at 04:42PM PDT, ID: 23230364
[x]
Attachment Details

C: Discern if variable is a file name or directory name

Asked by jchristn123 in C Programming Language

Tags: C, NA, NA

Hello,

Is there a simple way in C to take input from the user either via fgets or char array coming into main and then discern whether it is a file or a directory that is being referenced?

i.e. if I ask the user:

"Please enter a filename"

and they supply text, how can I within C check to see if they supplied me the name of a file or a directory?

Thanks!Start Free Trial
[+][-]03.10.2008 at 04:44PM PDT, ID: 21091672

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.10.2008 at 04:49PM PDT, ID: 21091711

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.10.2008 at 04:53PM PDT, ID: 21091738

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.10.2008 at 04:57PM PDT, ID: 21091759

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.10.2008 at 05:02PM PDT, ID: 21091781

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: C Programming Language
Tags: C, NA, NA
Sign Up Now!
Solution Provided By: ozo
Participating Experts: 2
Solution Grade: A
 
 
[+][-]03.10.2008 at 05:02PM PDT, ID: 21091784

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628