newline character

Reply

Join Date: Sep 2007
Posts: 13
Reputation: megan-smith is an unknown quantity at this point 
Solved Threads: 0
megan-smith megan-smith is offline Offline
Newbie Poster

newline character

 
0
  #1
Sep 30th, 2007
what is a newline character and what does it do?
for example, what does " variable != '\n' " mean?

And is there any other way to write" if (variable != '0' && variable != '1' && variabel != '\n') "?
I've tried " if (variable < '0' && variable > '1' && variabel != '\n') " , but it wouldn't work.
thanks
Last edited by megan-smith; Sep 30th, 2007 at 7:06 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,151
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1436
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: newline character

 
0
  #2
Sep 30th, 2007
In a word processor when you hit the <Enter> key the cursor will move one line down and all the way to the left margin. That is what the '\n' character simulates in text files. When you load a text file that contains newlines in Notepad or some other word processor you will see that behavior. Remove the newlines and everything will appear on the same line.

Exactly what is put in text files depends on the operating system -- MS-Windows adds two characters to the text file while both *nix and MAC add only one character.
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 13
Reputation: megan-smith is an unknown quantity at this point 
Solved Threads: 0
megan-smith megan-smith is offline Offline
Newbie Poster

Re: newline character

 
0
  #3
Sep 30th, 2007
thanks for the explanation.
now i understand what it means.
but what about " variable != '\n' " in an if command?
what does it mean " if variable is not '/n'?
and is there any other way of writing " if (variable != '0' && variable != '1' && variabel != '\n') "?
i told ya what i tried but it did not work!

thanks again.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,151
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1436
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: newline character

 
0
  #4
Sep 30th, 2007
>>what does it mean " if variable is not '/n'?
If the '\n' character has not been encountered -- normally signifies the end of a string in text files. '\0' indicates the end of the string in memory, assuming it is a normal c-style character array.

>>and is there any other way of writing
Could be done like this:
  1. char str[] = "01\n";
  2. if( strchr(str,variable) != 0)
  3. {
  4. // found it
  5. }
Last edited by Ancient Dragon; Sep 30th, 2007 at 9:17 pm.
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 13
Reputation: megan-smith is an unknown quantity at this point 
Solved Threads: 0
megan-smith megan-smith is offline Offline
Newbie Poster

Re: newline character

 
0
  #5
Oct 1st, 2007
Thanks!
I appreciate it.
Last edited by megan-smith; Oct 1st, 2007 at 1:29 am.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC