[prog] Strings in C

Therese Gustafsson th_gustafsson at yahoo.com
Fri Oct 18 12:58:09 EST 2002


--- Meredydd Luff <meredydd at everybuddy.com> wrote:
> Another proviso with fgets() - it puts a newline
> onto the end of any string 
> it reads. So, for example:
> 
> char mystr[64];
> 
> fgets(mystr, 64, stdin);
> 
> If I type "Hello" into that program, mystr will look
> like this:
> 
> {'H', 'e', 'l', 'l', 'o', '\n', '\0', ...}
> 
> Meredydd

Ah! This must be what I thought the '\0' was doing to
the database. Because when I did an insert with a
string that I had just read in from user input there
was a newline after it in postgresql (not very nice).
I thought that the '\0'-character did that, that's why
I wanted to get rid of it. But I see now that it's
actually the '\n' I want to get rid of then if I use
fgets()...

Thanks for the info!

/Therese

__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com



More information about the Programming mailing list