![]() |
|
Algorithms and flowcharts (Yet another C++ assignment). - Printable Version +- Southperry.net (https://www.southperry.net) +-- Forum: Social (https://www.southperry.net/forumdisplay.php?fid=14) +--- Forum: Rubik's Cube (https://www.southperry.net/forumdisplay.php?fid=58) +--- Thread: Algorithms and flowcharts (Yet another C++ assignment). (/showthread.php?tid=66984) Pages:
1
2
|
Algorithms and flowcharts (Yet another C++ assignment). - SaptaZapta - 2013-09-25 Yeah, you deleted my line " ch = NonWhiteChar(inF);" which was the first one in the do {} loop. That is where ch gets a value (which is the next character in the input file, skipping any whitespace). You could replace it temporarily with "inF >> ch;" and make sure your input file has no blanks and such for now. Once that works, we can step up to dealing with the whitespace. Algorithms and flowcharts (Yet another C++ assignment). - MariettaRC - 2013-09-25 SaptaZapta Wrote:Yeah, you deleted my line " ch = NonWhiteChar(inF);" which was the first one in the do {} loop. I actually did notice that and put it back in before; however, I still got the same error. Seeing your explanation, I'm even more confused as to why now. :| Algorithms and flowcharts (Yet another C++ assignment). - MariettaRC - 2013-09-25 *rubs head* http://pastebin.com/BBZjzhn3 This is my entire code right now. When I run it to at least try to declare the number of words in file, it does nothing after entering the filenames. It might be caught in an infinite loop? Either way, it doesn't seem to go beyond the GetWord function. I'm sure I'm doing loads of things wrong here. Algorithms and flowcharts (Yet another C++ assignment). - SaptaZapta - 2013-09-25 MariaColette Wrote:*rubs head* OK. Your main loop is Code: while (inF >> word)Also, if you do "inF >> word" you are eating up pieces of input, so GetWord()'s behavior will be wrong. If your idea here was just to count input words, comment out the call to GetWord. i.e., something like this: Code: while (! inF.eof())But let's see if we can get GetWord to do something, at least. The terminator bit should look like this Code: if (ch == ':')your main program's loop should be Code: doIf you still have time (sorry, was sleeping again :-() I would like you to try replacing the "inF >> ch" in GetWord with "ch = NonWhiteSpace(inF)" (of course adding that function as I wrote it upthread). Also your InsertWord function is perfect as it is. It doesn't need to determine the line because the line is passed to it. The way you would go about calling it is like this (main()'s main loop) Code: PARAGRAPH text;Algorithms and flowcharts (Yet another C++ assignment). - MariettaRC - 2013-09-25 I ran out of time, but that's all right, not your fault. I'm still going to at least get this to run, so I can at least understand the process. I have yet another assignment due on the 28th (I don't know why on the 28th, he said he'd only assign a program once a week...), so I'll be coming back with more questions starting tomorrow. @_@ This one SEEMS like a short one, but I'll see once he lectures us on it tomorrow... Thanks anyway, you've been a real help. |