output file display -- Need Help

This is a discussion on output file display -- Need Help within the C Programming forums, part of the General Programming Boards category; Hi everyone, It has been a whlie since I wrote a program, and shamfully I didn't really learn C that ...

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    2

    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.

    Attempt:

    Code:
     
    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
    Posts
    127
    Code:
    system("cat temp");
    That might help.
    ~Sven
    Windows XP Home Edition - Dev-C++ 4.9.9.2
    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.
    board.theprogrammingsite.com

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    2
    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, 08:51 PM
  2. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 04:44 PM
  3. I'm not THAT good am I?
    By indigo0086 in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 10-19-2006, 11: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, 04:28 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21