CFanatic

Go Back   CFanatic > Programming > C Programming

Join CFanatic Forum Now

a function that takes 3 command-line arguments topic posted under C Programming which is a part of Programming category in CFanatic Forum
Reply
 
Thread Tools Display Modes
  #1  
Old 01-06-2008, 01:33 AM
Junior Member
 
Join Date: Jan 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
new4c is on a distinguished road
| More
a function that takes 3 command-line arguments

I really need help on this one. Can't believe getting this kind of question as a newbie to C programming. Thanks alot
Write a program that takes 3 command-line arguments – the first is a flag, then second is a character, the third is a filename. If the flag argument is ‘s’ then it prints only those lines in the file that contain the character. If the flag argument is ‘-n’ then it prints only those lines in the file that do *not* contain the character.
Reply With Quote
  #2  
Old 03-22-2008, 03:02 PM
Junior Member
 
Join Date: Mar 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Mahesh.Shetye is on a distinguished road
| More
Re: a function that takes 3 command-line arguments

Quote:
Originally Posted by new4c View Post
I really need help on this one. Can't believe getting this kind of question as a newbie to C programming. Thanks alot
Write a program that takes 3 command-line arguments – the first is a flag, then second is a character, the third is a filename. If the flag argument is ‘s’ then it prints only those lines in the file that contain the character. If the flag argument is ‘-n’ then it prints only those lines in the file that do *not* contain the character.
you shud use main(int argc, char* argv[]) function insted of main() function in your program.
Reply With Quote
  #3  
Old 06-28-2008, 01:53 AM
Junior Member
 
Join Date: Jun 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
wesley001 is on a distinguished road
| More
Re: a function that takes 3 command-line arguments

and for more control about argument handling you can use getopt (from GNU).
and else like Mahesh.Shetye said:

Code:
#include <stdio.h>

int main(int argc, char *argv[])
{
if(argc!=4){
printf("Usage: %s <flag> <char> <file>",argv[0])
return 0;
}
// remaining code here
return 0;
}
Reply With Quote
  #4  
Old 12-29-2008, 01:14 AM
Junior Member
 
Join Date: Mar 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
heavensgate15 is on a distinguished road
| More
Re: a function that takes 3 command-line arguments

wow... nose bleed....
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Command Line Compile + Subdirectory DLL Not Working? will C# Programming 1 10-18-2008 09:41 PM
Too Few Arguments Error veronicak5678 C Programming 1 10-02-2007 01:06 AM
how to pass the arguments to procedure to close the window vidhya Win32 Programming 0 05-30-2007 05:24 AM
how to store the command line arguments which are passed in previous execution vidhya Win32 Programming 2 05-24-2007 01:28 AM
csproj command line build .NET1.1 codeunlock C# Programming 0 04-29-2007 12:46 AM

 

Advertisement

CFanatic Search
Custom Search

Advertisement

All times are GMT -5. The time now is 03:08 PM.



Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2010, Crawlability, Inc.
Cfanatic.com is a premier member of the IDG TechNetwork. For advertising opportunities contact here
Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board