I really need help on this c program!!! pleaaasseeee

C

Clever Monkey

Keith said:
The price to be paid for getting free help from experts is that
they're usually right.
In my experience those who are most dissatisfied with free help from
experts are also those that have asked questions assuming they already
know the answer.

When the answers they get do not match the answers they expect some
folks react as if the correct answer was a personal attack, perhaps as a
result of a carefully constructed preview that is no longer valid. A
more constructive path would be to assume the experts are right within
the parameters that they've established and then do your own research to
test the assumptions this leads you to.

It can be hard not to hold on to incorrect assumptions. The lucky thing
for us is that the C language is pretty firmly established (compared to
other sorts of human knowledge spaces) and is knowable in a very
complete sort of way. Experts, gurus and wizards are just those sorts
of people that have gained enough experience and knowledge to have that
privilege.

This is not to say some young gun could come along and turn the current
C paradigm on its head. It's just pretty unlikely.
 
C

Clever Monkey

Bill said:
Tosha said:
That won't work on turing machine also.

To the OP, who wanted a simple example:
all of the complaints that my code will not work
are accurate. To those making complaints:
the code does an absolutely perfect job of
giving the OP somewhere to start. Back to the
OP: instead of using 'a' + rand()%26, you can
do:

char * alphabet = "abcde...";
and get the value with:
alphabet[ rand() % length];

That gives you control over your definition of "letter"
and doesn't rely on the system's ordering.
This is one of the first things I thought of when I read the OP's
message. Even a trivial program like this can open design questions
like "how is 'letter' to be defined?" I guess if I wanted to get this
across better, I should have had a step (0) in my iterative development
process:

0. Determine the exact scope of what the program is to do in terms of
locale, alphabet and expectation.

Though I do admit the OP just wanted a quick homework solution --
something that will probably never be revisited. Why pass up an
opportunity to inject a little humour and also be (slightly) helpful?
The OP should be encouraged to think of the big picture!

Having been bitten in the proverbial by code that assumes all sorts of
things about "characters" on all sorts of platforms in all sorts of
locales, I have a hard time assuming ASCII for even this simplest
example. Other design questions that spring to mind are "how much
randomness is required?" and "is letter case and collation sequence
significant?" or even "can we assume only latin alphabets?"

I flatter myself with the notion that this is from learning to think
like a coder, but I have to admit it is just defensive behaviour from
working as a maintenance coder.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,181
Messages
2,570,971
Members
47,537
Latest member
BellCorone

Latest Threads

Top