array length check

This is a discussion on array length check within the C++ Programming forums, part of the General Programming Boards category; ERrrm, i'm new here. and i'm a beginner in programming i was wondering if there was a function to check ...

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    8

    array length check

    ERrrm, i'm new here. and i'm a beginner in programming

    i was wondering if there was a function to check the array length
    example:

    char array[50] = "Blah";

    is there a way to check how long "blah" is? (in otherwords, how many spaces are actually used in the array[50])

    all your responses are greatly appreciated.

  2. #2
    eh ya hoser, got a beer? stumon's Avatar
    Join Date
    Feb 2003
    Posts
    323
    Just use the sizeof() keyword.
    Code:
    cout << sizeof(blah);
    The keyboard is the standard device used to cause computer errors!

  3. #3
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361

    Re: array length check

    Originally posted by Derekkwok
    ERrrm, i'm new here. and i'm a beginner in programming

    i was wondering if there was a function to check the array length
    example:

    char array[50] = "Blah";

    is there a way to check how long "blah" is? (in otherwords, how many spaces are actually used in the array[50])

    all your responses are greatly appreciated.
    strlen(array);

  4. #4
    eh ya hoser, got a beer? stumon's Avatar
    Join Date
    Feb 2003
    Posts
    323
    hmm, I read that wrong, eibro is right for what you want.
    The keyboard is the standard device used to cause computer errors!

  5. #5
    Registered User
    Join Date
    Jul 2003
    Posts
    8
    thanks all

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. entering numbers to array in a row whithout length input
    By transgalactic2 in forum C Programming
    Replies: 55
    Last Post: 01-02-2009, 04:02 AM
  2. the length of my array is not what I expected
    By luca in forum C Programming
    Replies: 7
    Last Post: 12-05-2006, 03:14 AM
  3. array length question
    By cs_newbie in forum C Programming
    Replies: 24
    Last Post: 10-12-2006, 10:10 AM
  4. Template Array Class
    By hpy_gilmore8 in forum C++ Programming
    Replies: 15
    Last Post: 04-12-2004, 12:15 AM
  5. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 10:48 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21