string in an array

Discussion in 'C' started by Alex, Apr 12, 2009.

  1. Alex

    Alex New Member

    Joined:
    Oct 1, 2006
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    0
    I have a doutb about allocating memory and storing a string inside it.
    It may sound a very stupid question, but I need to clear it...
    My doubt comes when declaring a array bigger than the string it is
    going to be stored inside it:
    char* array = malloc( sizeof(char)*1024 );
    strcpy( array, "hello" );
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice