HEEELP

Create an application that uses the structure Item with fields: brand name, price, code. Create an array of such items from 10 items filled from the keyboard. You can do a product search by code, you can also enter part of the code, you have to output all the goods (their names and prices) that have that part of the code in your code. I need to use strstr. Can somebody help with that one? I have no idea how to do it

c++
Last edited on
Hello skorpas,

The first question you raise, is this a C or C++ program?

This is your work, so you need to do something first and post it. It does not matter if it is right or wrong, but it will show what you need help with.

Are you stuck with using an array or can you use a vector? A vector would make things easier.

I find that reworking the instructions can help:

1. Create an application that uses the structure Item with fields: brand name, price, code.

2. Create an array of such items from 10 items filled from the keyboard.

3. You can do a product search by code, you can also enter part of the code,
   you have to output all the goods (their names and prices) that have that part of the code in your code.

4. I need to use strstr.

Can somebody help with that one? I have no idea how to do it


After that it is easier to work in small steps, compile often and test often until you have what you want.

I would start with 1 followed by getting the user input to fill one struct. After that putting it into an array or vector is not that difficult.

As for "strstr" I am rather rusty with C these days, so I would start with
http://www.cplusplus.com/reference/cstring/strstr/
If that did not answer my questions you can try
https://en.cppreference.com/w/c/string/byte/strstr
or a Google search.

C++ string class has very good functions for finding part of a string.

Hope that helps,

Andy
Topic archived. No new replies allowed.