Thread: output file display -- Need Help

  1. #1
    Registered User
    Join Date
    Apr 2006

    output file display -- Need Help

    Hi everyone,

    It has been a whlie since I wrote a program, and shamfully I didn't really learn C that well, but I do have background in several programming languages. So now I ran into a problem when coding an assignment.

    Problem: My program needs to send unix command from client to server, and on server side, it will execute and output the command into a file and display the file on the client's screen.


    system(cat temp);
    where temp is the file that contain the executed unix command.

    It will output the file to the screen, but it only displays the previous executed one. For example, if there are nothing in the file at begining, then if I type "ls", it will display nothing, but if I type "pwd", then it will displays the output of "ls".What do I need to do in order to display right? Thanks in advance.

  2. #2
    Registered User 00Sven's Avatar
    Join Date
    Feb 2006
    system("cat temp");
    That might help.
    Windows XP Home Edition - Dev-C++
    Quote Originally Posted by "The C Programming Language" by Brian W. Kernignhan and Dennis M. Ritchie
    int fflush(FILE *stream)
    On an output stream, fflush causes any buffered but unwritten data to be written; On an input stream, the effect is undefined. It returns EOF for a write error, and zero otherwise. fflush(NULL) flushes all output streams.

  3. #3
    Registered User
    Join Date
    Apr 2006
    Thanks, but I did have the " ", just forgot to input it here.

    BTW, a friend of mine said the file might need to close, but I don't see why I need to close it if I didn't call it in the code.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need Help Fixing My C Program. Deals with File I/O
    By Matus in forum C Programming
    Replies: 7
    Last Post: 04-29-2008, 07:51 PM
  2. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  3. I'm not THAT good am I?
    By indigo0086 in forum A Brief History of
    Replies: 2
    Last Post: 10-19-2006, 10:08 AM
  4. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  5. Simple File Creation Algorithm
    By muffin in forum C Programming
    Replies: 13
    Last Post: 08-24-2001, 03:28 PM