Thread: creating a filter program for chaining

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

    creating a filter program for chaining

    Hello hello
    This is my first visit to this site but it's amazing.....I've searched the FAQ and scanned quickly through all the current threads but I couldn't find this topic anywhere. I want to write a series of programs that work as simple filters. IE. Enter a string and output only the number of characters in the string. I would like to be able to feed the data fromt the keyboard or route the input from a file. Is there anything special in the way the input has to be read or written. Can it simply be a scanf(), fscanf() [printf() or fprintf() for output] statements and chained from the command line....sorry to be rattling on...


  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    9
    > IE. Enter a string and output only the number of
    > characters in the string. I would like to be able to
    > feed the data fromt the keyboard or route the input
    > from a file.

    With input from a keyboard, you can simply use a counter variable and a getchar():

    counter=0;
    while ( (c=getchar()) != EOF )
    counter++;

    With input from a file, this can be done just as easily with a counter variable and a getc() function:

    counter=0;
    while ( (c=getc(fp)) != EOF )
    counter++;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem creating program to the specific specification
    By rushhour in forum C++ Programming
    Replies: 22
    Last Post: 11-28-2008, 12:15 AM
  2. creating a program to help with modding
    By chuck22 in forum C++ Programming
    Replies: 9
    Last Post: 02-16-2006, 10:16 AM
  3. insufficient memory for tsr
    By manmohan in forum C Programming
    Replies: 8
    Last Post: 01-02-2004, 09:48 AM
  4. Date program starts DOS's date
    By jrahhali in forum C++ Programming
    Replies: 1
    Last Post: 11-24-2003, 05:23 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM