Results 1 to 4 of 4

Thread: a C .exe doesn't read writeToStdin

  1. #1
    Join Date
    Sep 2006
    Posts
    4
    Thanks
    2
    Qt products
    Qt3
    Platforms
    Windows

    Default a C .exe doesn't read writeToStdin

    Please help:

    At first I thought QProcess is wrong now by putting in the wroteToStdin signal I determined my .exe written in C doesn't read the stdin.

    This is the code:
    Qt Code:
    1. fgets(serialnmr,sizeof(serialnmr),stdin);
    To copy to clipboard, switch view to plain text mode 

    serialnmr is char * and scanf nor gets works

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: a C .exe doesn't read writeToStdin

    Remember that you need a newline when reading using scanf() or gets().

  3. The following user says thank you to wysota for this useful post:

    Shlainn (20th September 2006)

  4. #3
    Join Date
    Sep 2006
    Posts
    4
    Thanks
    2
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: a C .exe doesn't read writeToStdin

    just to make sure I understand:

    for using scanf() and gets() the writeToStdin must be:
    Qt Code:
    1. proc->writeToStdin("tester\n");
    To copy to clipboard, switch view to plain text mode 

    because my code in my QT side is:
    Qt Code:
    1. proc->writeToStdin("tester\n");
    To copy to clipboard, switch view to plain text mode 
    but I use it with:
    Qt Code:
    1. fgets(serialnmr,sizeof(serialnmr),stdin);
    To copy to clipboard, switch view to plain text mode 

    and another thing I see is that nothing is displayed using readFromStdout until the program (my.exe) has exited.

    I'm really in a bind please help!

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: a C .exe doesn't read writeToStdin

    [QUOTE=Shlainn;20118]but I use it with:
    Qt Code:
    1. fgets(serialnmr,sizeof(serialnmr),stdin);
    To copy to clipboard, switch view to plain text mode 
    It doesn't matter. You still need the newline to flush the stdin buffer of your application.

    and another thing I see is that nothing is displayed using readFromStdout until the program (my.exe) has exited.
    Maybe you are missing newlines here, too... In the output buffer this time. You can use fflush() instead of the newline to force the flush too.

  6. The following user says thank you to wysota for this useful post:

    Shlainn (20th September 2006)

Similar Threads

  1. How to read line from file
    By Krishnacins in forum Newbie
    Replies: 10
    Last Post: 2nd June 2006, 00:14
  2. Replies: 13
    Last Post: 1st June 2006, 15:01

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.