Thread: no redirection

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    1

    Talking no redirection

    hi, this is my first post here. you came highly recommended i am doing a project for homework that deals with hashing, but i am getting caught up on something that i don't think is supposed to be that big of a problem.

    it requires the names of 6 files to be scanned in. I know how to do this after the program is running, but the catch here is that the names are being put in directly after the a.out.

    i've gotten the program to work if i type a.out, hit enter, then enter the name of the file. but if i type the name of the file before hitting enter, it won't work.

    so, its supposed to be put in like this :
    Code:
    $ a.out file1 delete1 ans1 ans2 ans4 ans5

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Code:
    #include <stdio.h>
    
    int main(int argc, char *argv[])
    {
       if ( argc < 2 )
       {
          puts("input filenames here");
       }
       else
       {
          int i;
          puts("filenames from command line:");
          for ( i = 1; i < argc; ++i )
          {
             puts(argv[i]);
          }
       }
       return 0;    
    }
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. input redirection
    By sashaKap in forum C Programming
    Replies: 6
    Last Post: 06-25-2009, 01:59 AM
  2. Linux file redirection buffering issue !!!!
    By AirSeb in forum Linux Programming
    Replies: 8
    Last Post: 03-14-2009, 05:32 PM
  3. Implement Redirection for a simple shell
    By koooee in forum C Programming
    Replies: 4
    Last Post: 02-22-2009, 03:21 PM
  4. General a.out redirection question under Linux
    By merixa in forum C++ Programming
    Replies: 3
    Last Post: 11-07-2005, 05:36 PM
  5. redirection program help needed??
    By Unregistered in forum Linux Programming
    Replies: 0
    Last Post: 04-17-2002, 05:50 AM