CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2006
    Posts
    62

    another array question

    hey guys just wondering if when you put a word in a character array is this still classed as dealing with a character string?

    for example

    if i had a char array which was char example [100];
    and it contained "hello" would hello be classed as a string even though its in a char array?

    thanks.

  2. #2
    Join Date
    Feb 2002
    Posts
    5,757

    Re: another array question

    string comprised \0.

    Kuphryn

  3. #3
    Join Date
    Feb 2006
    Posts
    62

    Re: another array question

    huh?

  4. #4
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: another array question

    [ Moved thread ]

    To 1821. Please post your array or not related questions in the appropriate forum!
    Thanks!
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  5. #5
    Join Date
    Feb 2005
    Location
    Normandy in France
    Posts
    4,590

    Re: another array question

    Quote Originally Posted by 1821

    if i had a char array which was char example [100];
    and it contained "hello" would hello be classed as a string even though its in a char array?
    In C, the notion of string is not directly supported by the compiler...
    A C-style string is only a pointer to a char, such as this char is immediately followed by another char, which itself is followed by another char, up to a '\0' char.
    So, we can say that a pointer to the first char of a char[100] array, which contains various characters and a nul terminator, is a string.

    But, in reality, where chars of a string are stored doesn't matter for all string-manipulating functions.
    "inherit to be reused by code that uses the base class, not to reuse base class code", Sutter and Alexandrescu, C++ Coding Standards.
    Club of lovers of the C++ typecasts cute syntax: Only recorded member.

    Out of memory happens! Handle it properly!
    Say no to g_new()!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured