LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-26-2007, 06:07 PM   #16
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492

Quote:
Originally Posted by daYz
Is '\n' the only character that gets entered when pressing the enter key? I always thought it where both '\r' and '\n'.
The Enter key always send a single CR '\r'. If you are in cooked mode, this '\r' is replaced by the driver to a LF '\n' a.k.a newline.

When outputting characters in cooked mode, '\n' is replaced by CR+LF '\r\n'.

When you are in raw mode, characters are left unchanged.
 
Old 07-26-2007, 07:12 PM   #17
exvor
Senior Member
 
Registered: Jul 2004
Location: Phoenix, Arizona
Distribution: Gentoo, LFS, Debian,Ubuntu
Posts: 1,537

Rep: Reputation: 87
The best way is to just avoid using getchar on the standard input and use scanf and sscanf to parse input. Then again scanf brings the possibility of buffer overflows into the mix.
 
Old 07-27-2007, 05:15 AM   #18
daYz
Member
 
Registered: Nov 2003
Distribution: Ubuntu
Posts: 164

Original Poster
Rep: Reputation: 30
Guys, everyone thanks for the help. I have learned quite some things from you.

Regards,

Ben
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Konqueror opens multiple times sploit Linux - Newbie 18 07-14-2007 08:11 AM
Shutdown message appears multiple times kluetsch Slackware 12 03-12-2007 01:04 PM
same email, multiple times ?? (exchange... sorry) itsjustme General 1 01-14-2005 02:33 PM
Tar command copied multiple times? cbriscoejr Linux - General 1 11-12-2004 02:09 PM
running wget multiple times quickk Linux - Newbie 1 09-16-2004 06:53 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration