Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

"-f"

Posted on 2003-10-24
5
Medium Priority
?
294 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

664 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