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 tips on how to ask a good question run !howto ask.
95 messages ยท Page 1 of 1 (latest)
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 tips on how to ask a good question run !howto ask.
@tough breach
Your message appears to contain screenshots but no code. Please send code and error messages in text instead of screenshots if applicable!
here is my current code
here are the given files
Also the screenshots at the topic are in reverse order...
what's your question?
my question is how to even continue, i dont even know where to start with writing the while loop in main along with all the functions
well first, what do you need to do?
write main the main function that has the correct while loop
the main function needs to
open the dino direct file and validate if it can be opene d
start the loop to read from the file
inside the loop it should increment the appropriate accumulator variable.
call the carn or herb func
open the correct file (carn or herb)
then call the printdino func
close the file
After the loop completes that read in all the data and printed the data to the output files, then you can close the
input file.
then
print the results to the screen
The start of the loop and down haha
what does the loop iterate over?
what do you mean ? im like a beginner beginner
does it iterate over a file? a number?
file
the file being the dino direct
a loop usually does something until that condition is met. What is that condition?
Loops also can use a different value every time it loops over, this is called iteration
yes because in the files the text is seprated by '#'
so are you iterating over each "chunk" of text
so you're iterating over the strings delimited by #?
basically from my understanding the loop allows for input from the user then from there determines what function is being called to do that certain part of code. I would suppouse so (Gustavo) the whole point of the program is to get text from the files but the text needes from the file is seprated by #. Rald yes.
i see
are you able to write that loop that asks for the user to input what is required?
do you mean like a cin>> ?
if you need an input from the user directly, yes
the screenshots at the beginning explain what im trying to say in a much better way
I haven't read them, and will not read them
if you can't explain them, you don't understand the assignment (and I'll help you understand it)
i would say i understand and dont understand the assingment but i also dont think i am knowledable enough to even write the code if i fully understood the assingment
you need to break it down into smaller chunks that you understand
then connect the chunks together to make the program
how limited is your knowledge in cpp
that's not important tbh
if it's the current assignment they need to do, they're knowledgeable enough
like very limited
do you think you can write the pseudo code of what you need to do?
yes
most likely not
well
it's a lot easier than writing the real code
then its going to be incredibly difficult if u cant even write the pseudocode for it
ive got somewhat i need
just go a step down from this
basically, write the code in english. For example:
while input is not valid:
input = GetInput()
if input is valid:
break
cout << "Dinosaur Directery File Name" ;
getline(cin, userin);
while(userin == "dinoDirectery")
{
inFile.open("dinoDierectery.txt") ;
}
while(getline(inFile, tempstring , '#'))
{
}
while (inFile >> dinoname) {
where the second while is is where i am truly stuck i guess
```cpp
int main() {}
```
int main() {}
getline(cin, userin);
while(userin == "dinoDirectery")
{
inFile.open("dinoDierectery.txt") ;
}
while(getline(inFile, tempstring , '#'))
{
}
while (inFile >> dinoname)
what is the point of those loops?
okay first one while the user inputs directery file the file opens
why is it in a loop?
I guess so i could validate input
are you validating the input in the loop?
i guess
what are you doing if the input is not valid?
furthermore, what do you do if the input is valid?
i would loop the getline
if input is invalid
so the user can input something again
but that's not what this code does
obvisouly
why don't we start by fixing that then? ^^
okay yes
what are the steps that need to be done in that loop?
would the getline be inside the while loop
yes, we want to let the user make an input if what they entered is not valid
{
getline(cin, userin);
inFile.open("dinoDierectery.txt") ;
}
i guess whats confusing me here
is
wouldnt it be like while getline = dinodirect
then it would open the file
you can do that, yes
you also want to re-ask for a different input when the input is not valid, not when it is valid, correct?
how do i close this thread
!solved
You can only close threads you own
!solved
Thank you and let us know if you have any more questions!
This thread is now set to auto-hide after an hour of inactivity