Solved

"-f"

Posted on 2003-10-24
5
288 Views
Last Modified: 2010-04-22
This is my code:

#include <stdio.h>

int main()
{
      FILE *fptr;
      char buffer[80];
      fptr = fopen("data.txt","r");
      if(fptr == NULL)
      {
              printf("Error");
              exit(1);
      }
      else
      {
              while(fgets(buffer,80,fptr))
              {
                     printf("%s",buffer);
              }
              fclose(fptr);
       }
}      


Is there a way to execute this program with the first parameter as the
"-f" and the second parameter as the name of the textfile?. Then
the program will read the contents of the textfile and display.

Do we incoperate the -f as part of the program. Does it do any sort of validation or functionality. Please include some examples.

P.S I know the command line arguments.

Regards
Eugene
0
Comment
Question by:eugene007
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 3

Expert Comment

by:scn
ID: 9615055
man 3 getopt   (an example is included in the manpage)
0
 

Author Comment

by:eugene007
ID: 9618274
can u further explain, cause I dont have linux on my machine.
0
 
LVL 3

Expert Comment

by:scn
ID: 9619405
0
 

Accepted Solution

by:
RomMod earned 0 total points
ID: 11560631
Closed, no points refunded.
RomMod
Community Support Moderator
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question