| | |
\n
![]() |
•
•
Join Date: Oct 2009
Posts: 2
Reputation:
Solved Threads: 0
who can tell me what the use of "\n" is? and what the difference between and ;?
C Syntax (Toggle Plain Text)
scanf("%d",&j);
C Syntax (Toggle Plain Text)
scanf("%d\n",&j)
-1
#2 Oct 25th, 2009
In C, the '\n' character is a special type of character called a control character, these are characters that do something other then just display themselves, here is all the ones that I know:
\n = newline
\t = tab
\a = This one rocks, it makes the computer make a beeping sound
The difference between those follows:
Say you called the first one, then the user entered 'hello', j would now be 'hello', if you called the second one, j would be 'hello\n' and whenever you printed out j after the second one, it would print out hello followed by a newline
\n = newline
\t = tab
\a = This one rocks, it makes the computer make a beeping sound

The difference between those follows:
Say you called the first one, then the user entered 'hello', j would now be 'hello', if you called the second one, j would be 'hello\n' and whenever you printed out j after the second one, it would print out hello followed by a newline
Last edited by tomtetlaw; Oct 25th, 2009 at 6:54 am.
...
-7
#3 Oct 25th, 2009
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
Join Date: Oct 2009
Posts: 47
Reputation:
Solved Threads: 2
-1
#4 Oct 25th, 2009
if i use this in a program its keep on taking the return key
the program not getting terminated, whats the problem?
the program not getting terminated, whats the problem?
C Syntax (Toggle Plain Text)
scanf("%d\n",&j)
0
#5 Oct 25th, 2009
It discards unwanted white space.
A white-space character in the control string causes scanf() to skip over one or more leading white-space characters in the input stream.
A white-space character in the control string causes scanf() to skip over one or more leading white-space characters in the input stream.
C Syntax (Toggle Plain Text)
int main() { char ch,ch1; printf("Enter two chars : "); scanf("%c\n%c",&ch,&ch1); printf("\n%c\n%c",ch,ch1); return 0; }
Failure is not fatal, but failure to change might be. - John Wooden
1
#7 Oct 25th, 2009
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
![]() |
Other Threads in the C Forum
- Previous Thread: Reading few string from a .txt file
- Next Thread: difficulty in understanding functions in c language
| Thread Tools | Search this Thread |
#include adobe api array arrays asterisks binarysearch calculate char cm copyanyfile copyimagefile copypdffile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax database directory dynamic feet fflush fgets file fork forloop frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hacking hardware highest homework i/o include incrementoperators input interest kernel kilometer linked linkedlist linux linuxsegmentationfault list lists locate logical_drives loopinsideloop. match matrix meter microsoft motherboard mqqueue mysql number odf open opensource owf pattern pdf performance pointer posix probleminc process program programming pyramidusingturboccodes radix read recursion recv repetition research scanf scheduling scripting segmentationfault send sequential shape socket socketprograming stack standard string systemcall turboc unix user voidmain() wab win32api windows.h






