| | |
\n
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
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: 67
Reputation:
Solved Threads: 3
-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; }
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
Views: 216 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for C
adobe ansi api array arrays bash binarysearch centimeter char convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory drawing dynamic executable fflush file fork frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hardware highest homework i/o inches infiniteloop initialization interest kilometer km lazy linked linkedlist linux linuxsegmentationfault list locate logical_drives match matrix meter microsoft motherboard multi mysql open opendocumentformat opensource owf pattern pdf performance pointer pointers posix power problem probleminc program programming pyramidusingturboccodes read recursion recv repetition scanf scheduling segmentationfault send shape socketprograming spoonfeeding stack standard strchr string strings structures student suggestions system systemcall test testautomation unix user voidmain() wab win32 win32api windows.h






