Thread: Obtaining array dimension

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    24

    Obtaining array dimension

    What's the easiest way to obtain an array element from a user and placing it into memory? As a result, I need to read double values and call an already written function to read these values.

    Help?

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    1)Obtaining array dimension

    For char arrays:
    strlen() in <cstring>
    char text[] = "Hello world.";
    cout<<strlen(text);

    For strings:
    length() in <string>
    string text;
    cout<<text.length();

    Other arrays:
    sizeof(array_name)/sizeof(array_name[0])

    2)What's the easiest way to obtain an array element from a user and placing it into memory?
    Code:
    double numbers[20];
    
    for(int i=0; i<20; i++)
    {
        cout<<"Enter a floating point number:";
        cin>>numbers[i];
    }
    3)As a result, I need to read double values and call an already written function to read these values.

    some_function(numbers);
    Last edited by 7stud; 06-03-2003 at 06:41 PM.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    24
    thank you sir - i'll let you know how hte program goes as i'll be needing help thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating double dimension array.
    By apacz in forum C++ Programming
    Replies: 4
    Last Post: 05-23-2005, 12:39 PM
  2. Type and nontype parameters w/overloading
    By Mr_LJ in forum C++ Programming
    Replies: 3
    Last Post: 01-02-2004, 01:01 AM
  3. 2 dimension string array
    By djarian in forum C Programming
    Replies: 4
    Last Post: 05-05-2003, 12:47 AM
  4. two dimensional dynamic array?
    By ichijoji in forum C++ Programming
    Replies: 6
    Last Post: 04-14-2003, 04:27 PM
  5. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 08:31 AM