Thread: piping a file into my project

  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    24

    piping a file into my project

    Hey my project (to print out a tv guide) is coming together now. I've tested the lesser parts, but now I need to pipe in an xml file of programmes I get off the net to test my printer.

    The main function is in this file tvprogs, but I don't know whether I'm piping my test xml file in properly. What's the expected format?

    The print function has the tag
    Code:
    void printEpgText(Epg *pEpg, Filter *pFilter)
    I've no filter yet but the Epg pointer comes from
    Code:
    Epg *readEpg(const char* inputFilename)
    With these in mind I'm attempting to pipe my test file simple.xml like this:
    in terminal : tvprogs < simple.xml
    Code:
    int main(int argc, char *argv[])
    {
    	Epg* test = readEpg(argv[1]);
    	printEpgText(test, NULL);
      return EXIT_SUCCESS;
    any clues?

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    When you pipe a file to your application, you read it through stdin; it does not come in as an argument. To print what got sent to your app, just do:
    Code:
    char buffer[1024];
    fgets(buffer, sizeof(buffer), stdin);
    printf("Got: %s\n", buffer);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  3. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  4. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM
  5. Hmm....help me take a look at this: File Encryptor
    By heljy in forum C Programming
    Replies: 3
    Last Post: 03-23-2002, 10:57 AM