#Understanding instructions

1 messages · Page 1 of 1 (latest)

fervent perch
#

Im new to VS studio and I was trying to understand what my prof is trying to tell me to do since i already have some code included idk what this step is trying to say

quartz harnessBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For more information use !howto ask.

lofty beacon
#

You teacher is lifting the veil on unit testing. 👍

fervent perch
#

so pretty much the code given i dont need to use it?

#

or do i need to use it to implement it inside of my code

lofty beacon
#

Is the code you posted yours?
Or the teacher's?

fervent perch
#

teachers

#

i had like premade code that the teacher made me download

#

and like add into vs

lofty beacon
#

TRUE or FALSE?
You will have written _array_init() and _print_array().

fervent perch
#

i have this in my thing

#

so there technically has the 2?

lofty beacon
#

Okay, so you have those functions, but they are stubbed.

The teacher has given you some code. This code will test function _array_init(). And optionally it will also invoke _print_array().

You can just C&P that code into your file. I would suggest underneath functions _array_init() and _print_array().

In your main() you could call this test_init_array().
This is basically what a unit test would do under the hood.

fervent perch
#

ohhh ok

#

thanks for the help

lofty beacon
#

Ah hang on.

#include "array_functions.h"

I didn't spot this until just now.

Are you working in a multi-file project?
If so, paste your teacher's code in the file that contains main().
It's probably called "main.cpp", but doesn't have to be.

fervent perch
#

yea im working in multi file

#

i cnt find a file with main()

lofty beacon
#

I see a file called "main.cpp".

fervent perch
#

i added it in to this

#

is there a site where theres a explantion for the Includes

#

cuz some of the includes that were added in here i have never seen before

lofty beacon
#

No, don't paste it inside of main().

Paste it above.
Then in main() add a call to this function.

#

Near the top of main.cpp you need to also add

#include "array_functions.h"
fervent perch
#

i added the include inside of the main.cpp

#

i got this tho

fervent perch
lofty beacon
fervent perch
#

oh

#

mb thanks for catching that

lofty beacon
fervent perch
#

ohhh ok

#

and for the call functions

#

thats the thing where its like

#

private and public

lofty beacon
#

No, that's for classes.
I cannot see any classes in your code.

fervent perch
#

ohhh ok

#

is the " " supposed to be ' '

lofty beacon
#

Maybe it should be

#include "includes/array_functions.h"

It's difficult to make out the directory structure from a project-view window - especially if it's not an IDE that I am familiar with.
That's my excuse anyway.

fervent perch
#

LOL yea im like completely new to this

#

and like all this stuff i was introduced to never learned in my previous class

lofty beacon
#

In fact, it might even be

#include "includes/array_functions/array_functions.h"

We could fix this in your CMakeLists.txt, but I fear that would take even longer and may just confuse.

fervent perch
#

oh that one worked

#

for this include how come u used " " instead of < >

lofty beacon
#

"" is for local files in your project.
<> is for system and library headers.

fervent perch
#

ohhh ok

#

thanks for the help

#

if i have any more questions would i make a new post or just stick with this post

lofty beacon
#

Up to you.
Might be easier for you to stick with this one.
Then you have all the information neatly in one thread.

fervent perch
#

ok thanks for the help again

quartz harnessBOT
#

This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.

fervent perch
#

i had to include a array function in my code

#

i was given

#

#include "../../includes/stub/stub.h"

#

or add a array

#

but when i do

#

#include "includes/array_functions/stub/stub.h"

#

it doesnt work

#

i also tried to add it in front of the includes

#

and that didnt work as well

lofty beacon
#

This is a matter of finding out where file stub.h lives relative to the source file from where you want to include it and the correct amount of ../ repeats.
Tedious and it's not something that any of us can give a definitive answer to.
I have techniques, but it requires the use of the command line.

fervent perch
#

so essentially i would add it after the stub.h?

lofty beacon
#

Okay, the header file "stub.h" doesn't appear to be "above" your project in the folder structure.
Try #include "includes/stub/stub.h"

fervent perch
lofty beacon
#

Does the file actually exist?
Again, not a champion on VStudio project views, but my suggestion appears to be correct based on your screenshot from before.

If you are proficient in command line use, perhaps cd to the project root directory and run

dir /s stub.h
fervent perch
#

i have never used command lines before

exotic ibex
#

show your CMakeLists.txt

#

that’s where you would configure include dirs

#

or at least for your actual build anyway

#

for just the syntax check your do that by installing and configuring the C++ extension for VSCode

fervent perch
fervent perch
fervent perch
exotic ibex
#

I’m on mobile rn, not going to download a file

fervent perch
#

ok

#

uh for the wandbox

#

what do i do with it once i paste in the code

exotic ibex
fervent perch
#

like this?

#

this how u do it right

#

the thing is with this code my teacher was the one that provided that code

exotic ibex
#

yes I see that

#

I’m not sure

#

in a case like this you really should have proper directions to follow given by your teacher

#

if not then go to office hours

#

or ask your TAs in the next lab

fervent perch
#

alright thanks for the help tho