Another improvement: Instead of using this:
fputc('y',pipe); fputc(10,pipe); We can use: fputs("y\r",pipe); |
On that note, we could use
Code:
fputs("y\n"); |
I tried \n. It works. Is there any difference between \n and \r ?
P.S. You're supposed to use \ and not / |
thanks, the "\" is corrected.
I'm quite unsure about this, but I think the \r is a carriage return, while '\n' is whatever combination of carriage return and line feed constitutes a line delimiter on the current platform. |
On MS it it's CRLF (aka \r\n), whereas *nix systems just use LF (\n), hence the issue if you edit text on eg
MS Notepad and upload in binary mode to *nix. Just to be different, Mac uses CR, see http://www.websiterepairguy.com/articles/os/crlf.html |
I read the article, but I still don't understand the difference between a LINE FEED and a CARRIAGE RETURN. What should I use in my program? \n or \r ?
Also, how do you send combinations like Ctrl-C, Shift-F1 etc. through the program? |
On a typewriter, at the end of line you had to do two things - move the paper up one line and slide back over the the left. Moving up a line is the line feed and moving back to the left is the carriage return. Many early computer monitors were essentially remote type writers, so a special character was created for these. However, UNIX systems, Linux included, use only the line feed. DOS systems, like windows, use both. Some other systems use only the carriage return. Using '\n' ensures that your program uses the correct character(s) for the system it is on.
|
Code:
|
I went through the table. Where are the "Ctrl", "Shift", "F1" etc. characters?. How do I send combinations of these special characters? If I want to send "tysdf" followed by the Enter key, I would write fputs("tysdf\r");. What do I do if I want to send Ctrl-F1 ?
|
Does anyone know how these are sent?
|
All times are GMT -5. The time now is 03:25 AM. |