I am a student studying C++, I have been tasked to
create a program that at run-time displays the size of it's source file,
list all used characters(including punctuation of course) and their occurrence
then summarize by displaying the most occurring character and least occurring
character.
In keeping with the theme of software planning I am trying to organize my
plan of attack before coding my self into a corner, as the purpose of this exercise is to indicate the way we would approach the problem.
To that end I would ask that you read and make suggestions, I hope this makes some type of sense, it is only "pseudo pseudo code".
thanks
#include <iostream>
#include <ifstream>
using namespace std;
char str[MAX SIZE OF CHARACTER TABLE HERE] = "hw1.cc";
cout << strlen(str) << endl;
I keeping with the them of software planning I am trying to organize my plan of attack before coding my self into a corner.
I think you're overthinking this.
This mode of thinking would make sense if you had been given a large project that could span many months. What you have here is a very simple exercise with files that should take one, two hours tops; three if you're really slow. Don't think so hard. Think one possible solution and try it. If it doesn't work, don't think you've wasted two hours. You should now be readier than two hours ago for your next try.
You're still learning, you don't have to, and probably won't, get it right the first time. Hell, even professional developers don't always get it right the first time.
2.
Unsure of effect on program to read it's source while executing.
There is no effect. The source and the program are two entirely different entities. That's like asking what's the effect of blinking in space on a cow in Moscow.
3.
hash table to associative array
WHAT? Seriously? A hash table to store character frequencies?
Occam's Razor: When you have two competing theories that make exactly the same predictions, the simpler one is the better.
Always try to think about the simplest solution. Simple is easy to implement. Simple is easy to test and debug.
Well that doesn't really help me much besides in a general moral support kind of way, and I thank you for that, but is there any particular suggestions you could make?
1.
I keeping with the them of software planning I am trying to organize my plan of attack before coding my self into a corner.
I think you're overthinking this.
This mode of thinking would make sense if you had been given a large project that could span many months. What you have here is a very simple exercise with files that should take one, two hours tops; three if you're really slow. Don't think so hard. Think one possible solution and try it. If it doesn't work, don't think you've wasted two hours. You should now be readier than two hours ago for your next try.
You're still learning, you don't have to, and probably won't, get it right the first time. Hell, even professional developers don't always get it right the first time.
You are absolutely right about my over thinking this, I am likely to over engineer things due to my lack of general knowledge and anxiousness to do it in a "smart way", clearly pretty far from that. If you could suggest an area or two to investigate, I would be very grateful.
It appears that what you posted above is simply a set of disjoint notes.
Perhaps you could start by writing some algorithms.
Firstly, from a high level, how will you compute the size of the source file?
Secondly, what data structure will you use to keep track of characters seen and frequencies?
Thirdly, how will you, from that data structure, determine the most frequent and least frequent character?