suresh
suresh

Reputation: 4224

send the enter button input through pipe

how to send return(enter button) character through program in windows c/c++? I want to send an external program "user name" with enter button through pipe but "\n" and "\r" and EOF are not working.

consider if pPipe is the pipe stream for sending the data to the remote process stdin...

fprintf(pPipe,"username\n");

Upvotes: 0

Views: 446

Answers (2)

Jonathan Leffler
Jonathan Leffler

Reputation: 753585

You need to flush the data out of the I/O package buffers.

If you're using <cstdio> (or <stdio.h>) as shown, then:

fflush(fp);

Upvotes: 0

alexkr
alexkr

Reputation: 4670

You can use escape sequences.

Upvotes: 2

Related Questions