help wid /n

Status
Not open for further replies.

Shikher_neo

Broken In
hey, i have some prob wid da /n character.well as u know during output to a file a /n is converted into 2 characters.it increases the size and hense i am having prob in appending data through the for loop.using binary completely deleted all the /n.
please help me
 

victor_rambo

हॉर्न ओके प्लीज़
I am sure what you need, but if you are speaking about the 'newline' delimiter, then its "\n" and not "/n". You are using forward slash instead of back slash.
 
OP
Shikher_neo

Shikher_neo

Broken In
Re: help wid \n (also-how 2 display * during input ? )

sorry for the backslash.I actually meant \n.But i know it occupies 2 bytes one for the carriage return and another for line feed.But it is converted back to single char during input and 2 chars during output.so this is posing a prob.when i input a file to make some changes send it back and another program needs it for the same purpose because now the size is changed. please help.

ANOTHER THING
can someone suggest a way to display * instead of a character during input ie the password field in Console programs?
 

QwertyManiac

Commander in Chief
Use a non echoing getchar() method. And for each character grab, send * to stdout. It depends on your platform though, on Linux I use curses/ncurses for achieving this (noecho() function).

And same goes for your \n. Windows does the 2 things - Carriage Return and Line Feed (CRLF), while on Linux it'd just be a single Line Feed (LF), and on Macintosh it is just a Carriage Return (CR). Windows is the only one doing both characters.

I guess you can intercept that behavior since you know it happens that way?

P.s. What language? Some have inbuilt password masking functions.

P.p.s. I just realized that \n is just for newline, and not for carriage return too, which is \r. So I don't know how its occupying 2 bytes if its not specified to, maybe its Windows indeed at work? Perhaps use \n\r together to avoid this confusion.
 
Last edited:
Status
Not open for further replies.
Top Bottom