Thread: fflush

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    29

    fflush

    I have a program running, which is fflush'ing data in
    with the following sentance

    while ( fgets( output, sizeof output, stdin ) !=EOF )

    now i want to make a client program which start this server program and send a char this this server.. through fflash or something like that



    if i just start the server it waits for input, and as soon as i write eg "this is a test" it starts to check the char

    how do start the program and send a char like this is a test.

    is there any tutorials or something like that

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Do you want to redirect input to your program?

    program.c:
    Code:
    #include <stdio.h>
    
    int main(void) {
        int c;
    
        while((c = getchar()) != EOF) putchar(c);
    
        return 0;
    }
    file.ext:
    Code:
    This is some text.
    Hello, World!
    Code:
    C>program <file.ext
    This is some text.
    Hello, World!
    C>
    To redirect the program's output (ie, stdout) to a file, use the > character.
    Code:
    C>program <file.ext >output.ext
    C>type file.ext
    This is some text.
    Hello, World!
    C>
    The same redirection symbols work under Linux.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    Registered User
    Join Date
    Jan 2006
    Posts
    29
    thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fflush and fgetc question
    By spank in forum Linux Programming
    Replies: 3
    Last Post: 05-24-2007, 05:39 AM
  2. To fflush, or Not to fflush...
    By bjgough in forum C Programming
    Replies: 32
    Last Post: 08-19-2005, 12:56 AM
  3. When and where to use fflush (stdout)?
    By Micko in forum C Programming
    Replies: 8
    Last Post: 02-18-2005, 11:58 AM
  4. Problems with input and fflush
    By edugarcia in forum Linux Programming
    Replies: 1
    Last Post: 11-24-2004, 01:52 PM
  5. everyone's favorite...fflush
    By BungleSpice in forum C Programming
    Replies: 8
    Last Post: 03-12-2004, 11:53 AM