Re: bizzare strncpy()

Discussion in 'C Programming' started by sumit.sharma@wipro.com, Jul 9, 2003.

  1. Guest

    Can you try after doing malloc for "t"???

    Icky The Poo <> wrote in message news:<XlfHa.26018$>...
    > This will print h and some funky char after it... I made a little
    > configuration file program and I was fooling around with it and noticed it
    > did this when I only put a one character value for a configuration arg. I
    > was thinking its pretty bizzare... anyone know why it does this? I tracked
    > it down and found out that the reason my program was doing it was because
    > of strncpy!
    >
    > char *t, *t2;
    > t2 = malloc(50 * sizeof(char));
    > strcpy(t2, "hello");
    > strncpy(t, t2, 1);
    > printf("%s", t);
     
    , Jul 9, 2003
    #1
    1. Advertising

  2. Oooohhh you'll be told off for top-posting!!

    It seems the rules here are you can be as rude as you like, as long as you
    don't top-post!!


    <> wrote in message
    news:...
    > Can you try after doing malloc for "t"???
    >
    > Icky The Poo <> wrote in message

    news:<XlfHa.26018$>...
    > > This will print h and some funky char after it... I made a little
    > > configuration file program and I was fooling around with it and noticed

    it
    > > did this when I only put a one character value for a configuration arg.

    I
    > > was thinking its pretty bizzare... anyone know why it does this? I

    tracked
    > > it down and found out that the reason my program was doing it was

    because
    > > of strncpy!
    > >
    > > char *t, *t2;
    > > t2 = malloc(50 * sizeof(char));
    > > strcpy(t2, "hello");
    > > strncpy(t, t2, 1);
    > > printf("%s", t);
     
    Alan Gillespie, Jul 9, 2003
    #2
    1. Advertising

  3. Zoran Cutura Guest

    Alan Gillespie <> wrote:
    > Oooohhh you'll be told off for top-posting!!
    >
    > It seems the rules here are you can be as rude as you like, as long as you
    > don't top-post!!


    Rudeness is in the eye of the beholder. I consider top-posting to be
    rude.
    --
    Z ()
    "LISP is worth learning for the profound enlightenment experience
    you will have when you finally get it; that experience will make you
    a better programmer for the rest of your days." -- Eric S. Raymond
     
    Zoran Cutura, Jul 9, 2003
    #3
  4. On Wed, 9 Jul 2003 11:55:55 +0100, in comp.lang.c , "Alan Gillespie"
    <> wrote:

    >Oooohhh you'll be told off for top-posting!!


    please don't top post. And why invite flames by doing it when you know
    its not acceptable?

    >It seems the rules here are you can be as rude as you like, as long as you
    >don't top-post!!


    No, the rules here are that when making a C related post you can be
    relatively rude as long as you are factually correct. Excessive
    rudeness tends to get you ignored.

    On the other hand being rude to those who ignore the customs and
    requirements of a group is standard practice in the Real World, never
    mind Usenet or CLC.
    --
    Mark McIntyre
    CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
    CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>


    ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
     
    Mark McIntyre, Jul 9, 2003
    #4
  5. "Alan Gillespie" <> wrote (09 Jul 2003) in
    news:begsbu$a2j$ / comp.lang.c:

    > Oooohhh you'll be told off for top-posting!!
    >
    > It seems the rules here are you can be as rude as you like, as
    > long as you don't top-post!!


    If your name is "Alan Gillespie," you can purposely be rude by top-
    posting and wearing a sign "I'm Alan Gillespie, and I'm rude!".




    --
    Martin Ambuhl
    Returning soon to the
    Fourth Largest City in America
     
    Martin Ambuhl, Jul 9, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bill joyce

    Bizzare session variable issue

    bill joyce, Oct 18, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    348
    bill joyce
    Oct 20, 2003
  2. Keith-Earl
    Replies:
    1
    Views:
    2,025
    Peter O'Reilly
    May 3, 2004
  3. Replies:
    0
    Views:
    462
  4. JavaEnquirer

    Bizzare web start problem

    JavaEnquirer, Aug 24, 2005, in forum: Java
    Replies:
    3
    Views:
    1,577
    JavaEnquirer
    Aug 25, 2005
  5. Replies:
    0
    Views:
    348
Loading...

Share This Page