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?
Printable View
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?
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?
3)As a result, I need to read double values and call an already written function to read these values.Code:double numbers[20];
for(int i=0; i<20; i++)
{
cout<<"Enter a floating point number:";
cin>>numbers[i];
}
some_function(numbers);
thank you sir - i'll let you know how hte program goes as i'll be needing help thanks!