473,405 Members | 2,176 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

can someone explain this to me?

I'm a beginner in C++ and my teacher is not explaining the material correctly. I was wondering if I could get help
Feb 15 '08 #1
4 1103
Laharl
849 Expert 512MB
What problem are you having? What material is he not explaining well? We're gonna need more information than that to help you...
Feb 15 '08 #2
i'm in deltamami's class and this is what the teacher told us about those problems: well, about number one

first of all... this should not be a main( ) function...

second... the function should have an array passed to it (by passing a pointer to the first element), and an integer value that you will search for in the array, and one other variable that you will need for the loop control

third... the function should return a pointer to the value in the array

How will you find the value in the array? Loop through the array and compare each value to the value you are looking for. When you find the value, return the address of the value in the array (the location of the first element of the array plus the number of ints from the beginning of the array).

I dont understand what this means
What problem are you having? What material is he not explaining well? We're gonna need more information than that to help you...
Feb 15 '08 #3
is this right?
Expand|Select|Wrap|Line Numbers
  1. void loadArray(const int*, const int);
  2. int main()
  3. {
  4. //Declare variables
  5.     int myArray[5]; //IN: holds the array of integers
  6.     loadArray(myArray, 5); //IN: invokes loadArray
  7.  
  8.  
  9.  
  10.  
  11.       system("pause");
  12.       return 0;
  13.  
  14. }
  15.  
  16. void loadArray(const int *myArray, const int size)
  17. {
  18.     //Increments the address 
  19.     for(int i = 0; i< size; i++)
  20.      cout<<(myArray+i)<<endl; //My array is incremented and therefore prints out 
  21.                             //the information in the array
  22.  
  23. }

i'm in deltamami's class and this is what the teacher told us about those problems: well, about number one

first of all... this should not be a main( ) function...

second... the function should have an array passed to it (by passing a pointer to the first element), and an integer value that you will search for in the array, and one other variable that you will need for the loop control

third... the function should return a pointer to the value in the array

How will you find the value in the array? Loop through the array and compare each value to the value you are looking for. When you find the value, return the address of the value in the array (the location of the first element of the array plus the number of ints from the beginning of the array).

I dont understand what this means
Feb 15 '08 #4
Ganon11
3,652 Expert 2GB
Why not put it into a compiler and see what happens? I don't think you'll get quite what you want.

Alo, that function looks like it's trying to print the array - but the function name is loadArray - shouldn't you be inputting?
Feb 15 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Maciej Nadolski | last post by:
Hi! I can`t understand what php wants from me:( So: Cannot send session cache limiter - headers already sent (output started at /home/krecik/public_html/silnik.php:208) in...
6
by: Ken Varn | last post by:
Sometimes when I try to close my managed C++ application, the following dialog displays in Win 2000 Pro: The title of the dialog is "Server Busy". The message is "This action cannot be completed...
8
by: Peter Foti | last post by:
I'm working on a site and the client said he thinks "the main title should be around 28pt and the subtitle probably 18pt". I know pt's are bad, and I want to convince him that he should NOT be...
5
by: J Allen Horner | last post by:
I'm just starting to learn C, and the tutorial I'm reading uses this code as an example: ----------- #include <stdio.h> #define MAX 10 int a; int rand_seed=10;
5
by: klj_mcsd | last post by:
Let's say you set txtlastname1.visible = true Then DirectCast(Page.FindControl("txtLastName1"), TextBox).Visible = False Why when you check txtlastname1.visible it is equal to True?
4
by: Richard L Rosenheim | last post by:
Using Visual Studio 2003 running under Windows XP Pro w/SP 1, when I create a new form, the form's title bar has the Windows 2000 look. Yet, in the various Microsoft demos, the form's title bar...
3
by: Jan Nielsen | last post by:
Hi I am working with rowfilters in dataviews. I would like to filter for empty fields (= null value in the database) I found this sentence on msdn: **************** To return only those columns...
1
by: Simon Windsor | last post by:
Hi I have just recevived this error could not write to hash-join temporary file: No space left on device Can someone please explain how I can stop this occuring. Whereis the hash-join...
1
by: mansa | last post by:
a) A company receives hundreds of orders every week through the mail. Explain carefully how BATCH- PROCESSING might be used. Describe the role of the BATCH TOTAL in this process. Explain how batch...
6
by: Dave Young | last post by:
I'm looking at some code that i've inherited and I'm not really familar with what's going on here and was hoping somone could explain it to me. For reference: f1 is a long f2 is a long ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.