Re: char * vs char[]

Discussion in 'C++' started by =?iso-8859-1?Q?Juli=E1n?= Albo, Jun 25, 2003.

  1. C Wood escribió:

    > void some_func() {
    > char temp[] = "prepend"; /*This one*/
    > char *temp= "prepend"; /*Or this one*/
    > strcat(temp," before this");
    > }


    None of them. char temp []= "prepend"; allocates just the space needed
    for the characters of the string plus the zero terminator. If you strcat
    to it you are out of space.

    Regards.
     
    =?iso-8859-1?Q?Juli=E1n?= Albo, Jun 25, 2003
    #1
    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. wwj
    Replies:
    7
    Views:
    561
  2. wwj
    Replies:
    24
    Views:
    2,527
    Mike Wahler
    Nov 7, 2003
  3. Ben Pfaff
    Replies:
    5
    Views:
    482
    Tristan Miller
    Jan 17, 2004
  4. Steffen Fiksdal

    void*, char*, unsigned char*, signed char*

    Steffen Fiksdal, May 8, 2005, in forum: C Programming
    Replies:
    1
    Views:
    593
    Jack Klein
    May 9, 2005
  5. lovecreatesbeauty
    Replies:
    1
    Views:
    1,071
    Ian Collins
    May 9, 2006
Loading...

Share This Page