wrting function using pointers and list

C

chirag

hi i have hw assignment providing info below. please provide some code if
you can. thanks.


int lookupValue(List *listPtr, ListItemType item, bool &success)
// If an entry equal to item exists in the list pointed to by
// listPtr, returns the index of the position of the first occurrence
// of such an item and sets success to true. Otherwise success is set
// to false and -1 is returned.





void testLookupValue()
// Tests function lookupValue. Initializes a list using enterList,
// asks for a value to look up, and then passes them to lookupValue.
// If the value is found, prints the location in the list. Otherwise
// prints a message saying the value was not found.
 
H

Howard

chirag said:
hi i have hw assignment providing info below. please provide some code if
you can. thanks.

Nope. Try it yourself. That's what homework is for. If you get stuck on
some particular piece of code you've written, post it and we'll help point
out what's wrong and how you might fix it. But we don't do homework. That
doesn't help anyone.

-Howard
 
C

chirag

can you at least provide me some guidelines to start with cuz this is only
part of my hw assignment and this is the only one part wher i m stuck.
thanks.
 
D

Default User

chirag said:
can you at least provide me some guidelines to start with cuz this is only
part of my hw assignment and this is the only one part wher i m stuck.
thanks.

Nope. Show us what you have so far. What exactly is giving you trouble?
Do you know what a linked list is? How to traverse one? Compare
elements?

Note that we don't even have the definition for the list type.




Brian
 
H

Howard

chirag said:
can you at least provide me some guidelines to start with cuz this is
only
part of my hw assignment and this is the only one part wher i m stuck.
thanks.

You don't say where you are stuck. Do you have any code at all? Do you
know how to ask for data, how to read it in, and how to print out the
asnwer? Do you know how to create the list? Do you know how to search it?
We really can't help with such a vague question. For help with the problem
itself, you might ask someone in your class how they're doing it, or ask the
instructor for guidance. And if you have a question about something
*specific*, then ask it. (Books are also a great place to find specific
answers, as is the FAQ I already mentioned.)

By the way, it would also help if you used complete words (and punctuation
as well), instead of saying things like "wher i m stuck". This isn't Instant
Messenger, it's a newsgroup.

-Howard
 
J

Jesper Madsen

chirag said:
hi i have hw assignment providing info below. please provide some code if
you can. thanks.


int lookupValue(List *listPtr, ListItemType item, bool &success)
// If an entry equal to item exists in the list pointed to by
// listPtr, returns the index of the position of the first occurrence
// of such an item and sets success to true. Otherwise success is set
// to false and -1 is returned.
Just to get you going...
What would your List parameter and ListItemType look like?

void testLookupValue()
// Tests function lookupValue. Initializes a list using enterList,
// asks for a value to look up, and then passes them to lookupValue.
// If the value is found, prints the location in the list. Otherwise
// prints a message saying the value was not found.

Do you have the code for enterList???
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,201
Messages
2,571,048
Members
47,651
Latest member
VeraPiw932

Latest Threads

Top