Thread: unix fold utility

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    8

    unix fold utility

    Hello again! lol. I have to create a fold utility program as our final project (we had 3 choices). I am having trouble getting started on it. I will post a link to the description of what the fold command is supposed to do.

    http://www.conestogac.on.ca/~set/cou..._fold_2008.htm

    This is due on Tuesday btw.

    UPDATE: So far I have this...

    Code:
    #include <stdio.h>
    
    int main(int argc, char *argv[])
    {
    	FILE *inputFile; //pointer to a file//
    
    	if (argv[1] == '-s')
    	{
    	// Fold line after the last blank character within the first width column positions. 
    	// If there is no such character, fold anyway. 
    	}
    
    	if (argv[2] == '-w' && argv[3] == /* width variable here*/)
    	{
    	// Specify a line width to use instead of the default 80 columns.
    	}
    
    	inputFile = fopen(argv[4], "r"); //open a file for reading//
    
    	if (inputFile = fopen(argv[4], "r") == NULL)
    	{
    		printf("Cannot open file for reading.\n"); //display error if file is not found//
    		return -1;
    	}
    	
    	if (inputFile = fopen(argv[4], "r") != NULL)
    	{
    		return -2;
    	}
    
    	//other code here//
    
    	return 0;
    }
    I guess that separate functions would be a good idea to use for each command line argument?
    Last edited by Sgemin_001; 12-06-2008 at 03:12 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. which utility in UNIX
    By Ron in forum C Programming
    Replies: 15
    Last Post: 06-19-2008, 08:23 AM
  2. How to program in unix
    By Cpro in forum Linux Programming
    Replies: 21
    Last Post: 02-12-2008, 10:54 AM
  3. Setting up a Unix box
    By @nthony in forum Tech Board
    Replies: 6
    Last Post: 07-22-2007, 10:22 PM
  4. UNIX script
    By boshke in forum Linux Programming
    Replies: 2
    Last Post: 12-10-2001, 12:55 PM
  5. About Unix Programming - Making a career desision
    By null in forum C Programming
    Replies: 0
    Last Post: 10-14-2001, 07:37 AM