Thread: Arrays

  1. #1


    Please do not get offended , just started taking C++ seriously (about time).
    all that i wanna know is. Is there a function to help check on the arrays lenght ? something like:

    char array[100];

    while(int i= 0; i < array.length(); i++)

    i'm sure there's something like this, but i simply cannot find.

    thanks in advance for your time, and i promisse that tomorrow i'll go out and buy myself a really good book on C++


  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    I keep wanting to say strlen, but I'm not sure if there's another one for C++. Anyway, strlen should work.

    int main(){
      int array1[5];
      int array2[10];
      if(strlen(array1) < strlen(array2)){
        \*do stuff*\
      return 0;
    Though something about that isn't right to me, I wish I had K&R with me to double check...oh well, try it and see. I'm 99.9% sure that's it
    I think array.length is java code, not C++.


  3. #3
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    You can do -


    to obtain the length.

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    That's what I was trying to think of, sizeof(). Thanks zen, I was just short of pulling my hair out for not being able to remember something I knew was simple. Though it's always the simple ones that catch us off guard, right?


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function to read in two arrays
    By ssmokincamaro in forum C Programming
    Replies: 7
    Last Post: 11-12-2008, 07:59 AM
  2. pointers & arrays and realloc!
    By zesty in forum C Programming
    Replies: 14
    Last Post: 01-19-2008, 04:24 PM
  3. Replies: 16
    Last Post: 01-01-2008, 04:07 PM
  4. Need Help With 3 Parallel Arrays Selction Sort
    By slickwilly440 in forum C++ Programming
    Replies: 4
    Last Post: 11-19-2005, 10:47 PM
  5. Crazy memory problem with arrays
    By fusikon in forum C++ Programming
    Replies: 9
    Last Post: 01-15-2003, 09:24 PM