471,075 Members | 1,245 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,075 software developers and data experts.

compiling error

Need some help on this please:
EECE1207 Spring 2005

Computer Assignment # 1
Due Wednesday, March 23rd

The file ‘grades.txt’, as shown below, contains the results of a
true-false exam given to a group of students. You may assume that the
number of students will always be less than 20. The first line contains
the key answer representing the 10 correct answers. Starting from the
second line, each line of the data file contains the student
identification number and the student’s answer to 10 true-false
questions.
Write a program that reads as input the file ‘grades.txt’. The program
should start by readng the correct answer from the first line into a 1-D
character array named correct_answers, then do the following tasks:
Read the students ID numbers into a 1-D integer array named ID, and read
each student’s answers into a 1-D character array containing the answers
for the current student, named current_answers. The number of students,
num_students, should be determined in the process.
While reading the data in (1), compute and store the number of correct
answers for each student in a 1-D integer array named scores.
After reading all the data, determine the average score, AvgScore.
Finally, print a three-column table on the screen that displays the ID
number, the score, and the grade (Pass or Fail) for each student.

The grades should be determined as follows: If the score is larger than
AvgScore then the grade is Pass; otherwise the grade is Fail.

Contents of the file ‘grades.txt’:

FTFFTFFTFT
1080 FTTFTFTTFT
1340 FTFTFTTTFF
1341 FTTFTTTTTT
1401 TTFFTFFTTT
1462 TTFTTTFFTF
1464 FTFFTFFTFF
1465 TTTTTTTTTT
1466 FFFFFFFFFF
1467 FTFTFFTFTF
1468 FFTTFFTTFF
1469 TTTTTFFFFF
1470 FFFFFTTTTT

Note:
Your program must be written so that it could process a file with any
number of students.
Adequate comments should be placed throughout your program to briefly
describe it statements.

This is what I have so far:


#include<stdio.h>
AvgScore(int score[],int i){
int total;
int avg;
int j;
for(total = 0, j = 0; j < i; i++)
{
total += score[i];
}
avg = total/i;
return avg;
}
int main (void)
{
#define NUMSTUDENTS 20
#define NUMANSWERS 10
int ID[NUMSTUDENTS];
char correct_answers[NUMANSWERS+2];
char current_answers[NUMANSWERS+2];
int i=0;
int score[NUMSTUDENTS];
char *ptr1, *ptr2;
int avg;
FILE* fpi=fopen("grades.txt", "r");
//read correct answers
fscanf(fpi,"%s",&correct_answers);
//check for valid file
if(!fpi) printf("Did not open file");

while( !feof(fpi) ){
// read student-id
fscanf(fpi,"%d", &ID[i]);
// read answers
fscanf(fpi,"%s",current_answers);
i++;
// process data not shown
//i= num of students
}
fclose(fpi);

score[NUMSTUDENTS] = 0;
ptr1 = &correct_answers[0];
ptr2 = &current_answers[0];
for (i = 0; i < 10; i++){
if (*ptr1++ == *ptr2++)
score[i]++;
}
avg=AvgScore(score,i);

printf("%d\n",ID[i]);
printf("%d\n",score[i]);

for (score[i];score[i]<avg;score[i]++){
printf("Fail");}
for (score[i];score[i]>avg;score[i]++){
printf("Pass");}

return 0;

}
I keep getting a steam!=null error upon trying to execute the file, the
compiler shows no errors or warnings however. Any help would be greatly
appreciated. Thank you.

Nov 14 '05 #1
33 1525
In article <b7******************************@localhost.talkab outprogramming.com>,
nkhan <nk***@memphis.edu> wrote:
:Need some help on this please:

:#define NUMSTUDENTS 20

: int score[NUMSTUDENTS];

: score[NUMSTUDENTS] = 0;

Indices go from 0 to the (array size minus 1); 0 to NUMSTUDENTS-1
in this case. Thus score[NUMSTUDENTS] does not exist.

: for (i = 0; i < 10; i++){

Where did that 10 come from? Is that the same 10 as NUMANSWERS ?

: if (*ptr1++ == *ptr2++)
: score[i]++;
: }

But if the 10 is NUMANSWERS then you have the problem that you
are indexing score, which is the number of students, with the
answer number. Suppose there were only 5 students and 10 answers?

: avg=AvgScore(score,i);

What is this calculating the average score of? Students? Answers?

--
I was very young in those days, but I was also rather dim.
-- Christopher Priest
Nov 14 '05 #2
score[NUMSTUDENTS] = 9; better?

I was using the 10 to loop 10 times b/c it was defined in the problem
there were 10 answers...

The function is calculating the average score of students.
Nov 14 '05 #3
In article <be******************************@localhost.talkab outprogramming.com>,
nkhan <nk***@memphis.edu> wrote:
:score[NUMSTUDENTS] = 9; better?

No, you appear to have missed the point by a long shot.

Take a piece of paper and write on it one box for every array entry in the
array 'score'. Now simulate your code score[NUMSTUDENTS] = 9; and see
what you get.
:I was using the 10 to loop 10 times b/c it was defined in the problem
:there were 10 answers...

If 10 is a fixed number, then why did you bother #define'ing the number
of answers before?
:The function is calculating the average score of students.

Hint: it isn't. Take that piece of paper mentioned above and
hand-simulate a couple of iterations of your 'for' loop.
--
History is a pile of debris -- Laurie Anderson
Nov 14 '05 #4
score[NUMSTUDENTS] = 9; better?

I was using the 10 to loop 10 times b/c it was defined in the problem
there were 10 answers...

The function is calculating the average score of students.
Nov 14 '05 #5
nkhan wrote:
Need some help on this please:
EECE1207 Spring 2005

Computer Assignment # 1
Due Wednesday, March 23rd

The file ‘grades.txt’, as shown below, contains the results of a
true-false exam given to a group of students. You may assume that the
number of students will always be less than 20. The first line contains
the key answer representing the 10 correct answers. Starting from the
second line, each line of the data file contains the student
identification number and the student’s answer to 10 true-false
questions.
Write a program that reads as input the file ‘grades.txt’. The program
should start by readng the correct answer from the first line into a 1-D
character array named correct_answers, then do the following tasks:
Read the students ID numbers into a 1-D integer array named ID, and read
each student’s answers into a 1-D character array containing the answers
for the current student, named current_answers. The number of students,
num_students, should be determined in the process.
While reading the data in (1), compute and store the number of correct
answers for each student in a 1-D integer array named scores.
After reading all the data, determine the average score, AvgScore.
Finally, print a three-column table on the screen that displays the ID
number, the score, and the grade (Pass or Fail) for each student.

The grades should be determined as follows: If the score is larger than
AvgScore then the grade is Pass; otherwise the grade is Fail.

Contents of the file ‘grades.txt’:

FTFFTFFTFT
1080 FTTFTFTTFT
1340 FTFTFTTTFF
1341 FTTFTTTTTT
1401 TTFFTFFTTT
1462 TTFTTTFFTF
1464 FTFFTFFTFF
1465 TTTTTTTTTT
1466 FFFFFFFFFF
1467 FTFTFFTFTF
1468 FFTTFFTTFF
1469 TTTTTFFFFF
1470 FFFFFTTTTT

Note:
Your program must be written so that
it could process a file with any number of students.
Adequate comments should be placed throughout your program
to briefly describe its statements. cat main.c #include <stdio.h>

double average(const size_t n, int score[n]) {
int total = 0;
for (size_t j = 0; j < n; ++j) {
total += score[j];
}
return (double)total/n;
}

int main(int argc, char* argv[]) {
FILE* fpi = fopen("grades.txt", "r");
if (NULL == fpi) {
printf("Could not open file grades.txt!");
}
else { // (NULL != fpi)
const
size_t MAXANSWERS = 10;
char correct_answer[MAXANSWERS+1];
char current_answer[MAXANSWERS+1];
const
size_t MAXSTUDENTS = 20;
int ID[MAXSTUDENTS];
int score[MAXSTUDENTS];

size_t students = 0; // number of students
//Read correct answers.
fscanf(fpi, "%s", correct_answer);
while (!feof(fpi)) { //Check for valid file.
ID[students] = 0;
// Read student-id.
if (fscanf(fpi, "%d", &ID[students]) < 1)
break;
// Read answers.
if (fscanf(fpi, "%s", &current_answer[students]) < 1)
break;
score[students] = 0;
const
size_t answers = MAXANSWERS;
for (size_t answer = 0; answer < answers; ++answer) {
if (correct_answer[answer] == current_answer[answer])
++score[students];
}
++students;
// Process data not shown.
}
fclose(fpi);

if (0 < students) {
const
double averageScore = average(students, score);

for (size_t student = 0; student < students; ++student) {
printf("%d\n", ID[student]);
printf("%d\n", score[student]);
if (score[student] < averageScore) {
printf("Fail\n\n");
}
else {
printf("Pass\n\n");
}
}
}
}
return 0;
}
gcc -Wall -std=c99 -pedantic -o main main.c
./main

1080
8
Pass

1340
5
Fail

1341
6
Pass

1401
7
Pass

1462
6
Pass

1464
6
Pass

1465
6
Pass

1466
5
Fail

1467
6
Pass

1468
5
Fail

1469
5
Fail

1470
5
Fail
Nov 14 '05 #6
nkhan wrote:

score[NUMSTUDENTS] = 9; better?

I was using the 10 to loop 10 times b/c it was defined in the problem
there were 10 answers...

The function is calculating the average score of students.


Better than what? What function?

You need to learn to quote. Other messages are not necessarily
visible. In this case Robersons are never visible, because he
refuses to mark quotes properly, and is PLONKED (meaning I am never
annoyed by seeing his offerings - they go straight into the
garbage). Each article should stand on its own.

The only other answer I see is from our resident Troll, and while
it may work for him it probably won't for you, because you probably
don't have a C99 compiler. Besides, his answer is too baroque, and
your instructor is going to know you pirated it. It doesn't help
you learn anything.

Break your program up into usable small pieces. One is "read the
correct answers". Another is "fill the id / studentanswers
array". Another is "compute the average" (you did that). Probably
the last is "scan and emit grades". Each should be a function, and
receive (or deposit) its data through parameters. Each function
should be simple enough that you can trivially check its
correctness.

--
"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare
Nov 14 '05 #7
In article <42***************@yahoo.com>,
CBFalconer <cb********@worldnet.att.net> wrote:
:You need to learn to quote.

Yes, the OP should have given context.

: Other messages are not necessarily
:visible. In this case Robersons are never visible,

Never visible to -you- is different than "never visible".

:because he
:refuses to mark quotes properly,

Nonsense. My posts meet all RFC requirements. If your
newsreader messes them up then that's your problem.

:and is PLONKED (meaning I am never
:annoyed by seeing his offerings - they go straight into the
:garbage).

Did you manage to get the PLONKing right the third time?
The first two times you were back responding to me again
within days.
--
"This was a Golden Age, a time of high adventure, rich living and
hard dying... but nobody thought so." -- Alfred Bester, TSMD
Nov 14 '05 #8

"Walter Roberson" <ro******@ibd.nrc-cnrc.gc.ca> wrote in message
news:d1**********@canopus.cc.umanitoba.ca...
In article <42***************@yahoo.com>,
CBFalconer <cb********@worldnet.att.net> wrote:
:You need to learn to quote.

Yes, the OP should have given context.

: Other messages are not necessarily
:visible. In this case Robersons are never visible,

Never visible to -you- is different than "never visible".

:because he
:refuses to mark quotes properly,

Nonsense. My posts meet all RFC requirements. If your
newsreader messes them up then that's your problem.

:and is PLONKED (meaning I am never
:annoyed by seeing his offerings - they go straight into the
:garbage).

Did you manage to get the PLONKing right the third time?
The first two times you were back responding to me again
within days.

I think you'd make everyone on newsgroups alot happier if you used the ">"
character to denote a quote instead of ":". Using the colon makes the
quote, at a quick glance, undetectable. Using the standard ">" makes
viewing quotes very easy.

Dan
Nov 14 '05 #9
"Dan P." wrote:
"Walter Roberson" <ro******@ibd.nrc-cnrc.gc.ca> wrote
CBFalconer <cb********@worldnet.att.net> wrote:

.... snip ...

:and is PLONKED (meaning I am never
:annoyed by seeing his offerings - they go straight into the
:garbage).

Did you manage to get the PLONKing right the third time?
The first two times you were back responding to me again
within days.


I think you'd make everyone on newsgroups alot happier if you
used the ">" character to denote a quote instead of ":". Using
the colon makes the quote, at a quick glance, undetectable.
Using the standard ">" makes viewing quotes very easy.


As you can see he is too full of his own self-importance. He
doesn't even appreciate being given multiple chances and
explanations. Luckily most Canadians are not so anti-social. So
the only cure is to persuade everybody to PLONK him, and then maybe
he will go away.

--
"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare

Nov 14 '05 #10
Dan P. <dp***************@ec.rr.com> spoke thus:
I think you'd make everyone on newsgroups alot happier if you used the ">"
character to denote a quote instead of ":". Using the colon makes the
quote, at a quick glance, undetectable. Using the standard ">" makes
viewing quotes very easy.


It makes no difference at all to me - my newsreader recognizes ':' as
a valid quote character. Now S.M. Ryan's quote character, a '#', is
another story altogether.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #11
On 22 Mar 2005 08:58:22 GMT, ro******@ibd.nrc-cnrc.gc.ca (Walter
Roberson) wrote:
In article <42***************@yahoo.com>,
CBFalconer <cb********@worldnet.att.net> wrote:
:You need to learn to quote.

Yes, the OP should have given context.

: Other messages are not necessarily
:visible. In this case Robersons are never visible,

Never visible to -you- is different than "never visible".

:because he
:refuses to mark quotes properly,

Nonsense. My posts meet all RFC requirements. If your
newsreader messes them up then that's your problem.
It's not nonsense - it makes your replies hard to read, especially
when mixing quotes from others who use the conventional quote marking.
Why do you take such delight in causing a problem? What's the gain?
Some weird kind of ego trip?
:and is PLONKED (meaning I am never
:annoyed by seeing his offerings - they go straight into the
:garbage).

Did you manage to get the PLONKing right the third time?
The first two times you were back responding to me again
within days.


--
Al Balmer
Balmer Consulting
re************************@att.net
Nov 14 '05 #12
On Tue, 22 Mar 2005 14:16:02 +0000 (UTC), Christopher Benson-Manica
<at***@nospam.cyberspace.org> wrote:
Dan P. <dp***************@ec.rr.com> spoke thus:
I think you'd make everyone on newsgroups alot happier if you used the ">"
character to denote a quote instead of ":". Using the colon makes the
quote, at a quick glance, undetectable. Using the standard ">" makes
viewing quotes very easy.


It makes no difference at all to me - my newsreader recognizes ':' as
a valid quote character. Now S.M. Ryan's quote character, a '#', is
another story altogether.


It's not the newsreader, it's the human reader that's affected.

--
Al Balmer
Balmer Consulting
re************************@att.net
Nov 14 '05 #13
In article <8g********************************@4ax.com>,
Alan Balmer <al******@spamcop.net> wrote:
:On 22 Mar 2005 08:58:22 GMT, ro******@ibd.nrc-cnrc.gc.ca (Walter
:Roberson) wrote:
:>Nonsense. My posts meet all RFC requirements. If your
:>newsreader messes them up then that's your problem.

:It's not nonsense - it makes your replies hard to read, especially
:when mixing quotes from others who use the conventional quote marking.

Alan, my quoting style is there to make quotes -easier- to read
for humans. My quoting style uses a different character for
each indentation level, so that humans can tell which quote is which
at a glance. Humans are very good at pattern matching with distinct
characters, but not nearly as good at mentally counting rows of
repetitions of the same character once the count gets beyond
about 4.
:Why do you take such delight in causing a problem? What's the gain?

CBF fairly consistantly uses strong pressure tactics to attempt to
get people to confirm to his vision of what this newsgroup should
be like. I have so far seen no reason to meet any of his
demands, and good reasons not to in most cases.

:Some weird kind of ego trip?

When someone says the newsgroup equivilent of, "I'm going to hold my
breath until I turn blue unless you do things my way!" then one can
fuss around and conciliate them, or one can say "Go ahead and turn blue
then, we are not impressed by you!"

Someone has to take a stand, and though it is certainly not my usual
position to do so, it seems to have fallen onto me in this situation.

If it were Chris or Keith making the request, then I would give their
points serious consideration, as it appears to me that both of those
gentlemen are more interested in helping people than they are in
controlling others.
If anyone happens to be curious as to whether provocation is my usual
style, then you are invited to skim through the google groups archives
of my postings, http://groups.google.ca/groups?q=author%3Aroberson+ibd
(Yeah, that count that shows up is a pretty good approximation of
the number of posts I've made.) I think you will find that I am
seldom provocative without strong reason. Except perhaps in some
messages about politics, posted through my personal account @mts.net
on local wpg.* (Winnipeg) newsgroups.
--
Beware of bugs in the above code; I have only proved it correct,
not tried it. -- Donald Knuth
Nov 14 '05 #14
In article <42***************@yahoo.com>,
CBFalconer <cb********@worldnet.att.net> wrote:
:As you can see he is too full of his own self-importance.

No, but I am too empty of the self-importance of certain other people.

:So
:the only cure is to persuade everybody to PLONK him, and then maybe
:he will go away.

A major premise by which certain people attempt to control the
newsgroup is that there are too many newcomers who don't know what
the current clique rules are about what is acceptable and what
is not, and that if the newcomers are not brushed off right at
the beginning then there will not be enough time to deal with
everyone.

If the barbarian hordes really are waiting at the gates, then
there is no shortage of people who will not have PLONKed me
and whom I can be of some assistance to.

The circumstances under which mass PLONKing would have
a noticable effect is if there is the horde has reduced to
a trickle -- in which case there would no longer be a need
for the big "You have visited c.l.c. Now go home!" flag that
some tend to wave around.
--
Usenet is like a slice of lemon, wrapped around a large gold brick.
Nov 14 '05 #15
On 22 Mar 2005 18:00:21 GMT, ro******@ibd.nrc-cnrc.gc.ca (Walter
Roberson) wrote:
In article <8g********************************@4ax.com>,
Alan Balmer <al******@spamcop.net> wrote:
:On 22 Mar 2005 08:58:22 GMT, ro******@ibd.nrc-cnrc.gc.ca (Walter
:Roberson) wrote:
:>Nonsense. My posts meet all RFC requirements. If your
:>newsreader messes them up then that's your problem.

:It's not nonsense - it makes your replies hard to read, especially
:when mixing quotes from others who use the conventional quote marking.

Alan, my quoting style is there to make quotes -easier- to read
for humans.
It fails.
My quoting style uses a different character for
each indentation level, so that humans can tell which quote is which
at a glance. Humans are very good at pattern matching with distinct
characters, but not nearly as good at mentally counting rows of
repetitions of the same character once the count gets beyond
about 4.
Counting is not necessary. As you say, humans are very good at
patterns, and in this case, the pattern is the consistent indentation
and character, visible at a glance. With varying characters, of
varying widths, that pattern recognition is useless, and analysis of
the levels requires just that, analysis. The width issue can be
resolved at the cost of using a fixed-width font for everything, but
that has other disadvantages, and still leaves the distraction of a
mixture of quote characters.

:Why do you take such delight in causing a problem? What's the gain?

CBF fairly consistantly uses strong pressure tactics to attempt to
get people to confirm to his vision of what this newsgroup should
be like. I have so far seen no reason to meet any of his
demands, and good reasons not to in most cases.
I see. So you're inflicting this on all of us just to spite CBF.
:Some weird kind of ego trip?

When someone says the newsgroup equivilent of, "I'm going to hold my
breath until I turn blue unless you do things my way!" then one can
fuss around and conciliate them, or one can say "Go ahead and turn blue
then, we are not impressed by you!"

Someone has to take a stand, and though it is certainly not my usual
position to do so, it seems to have fallen onto me in this situation.
The short answer to my above question would seem to be yes.

If it were Chris or Keith making the request, then I would give their
points serious consideration, as it appears to me that both of those
gentlemen are more interested in helping people than they are in
controlling others.
CBF is not the only reader here who has made this request. Others have
asked, and politely. It seems to me that you are the one interested in
exerting control.
If anyone happens to be curious as to whether provocation is my usual
style, then you are invited to skim through the google groups archives
of my postings, http://groups.google.ca/groups?q=author%3Aroberson+ibd
(Yeah, that count that shows up is a pretty good approximation of
the number of posts I've made.) I think you will find that I am
seldom provocative without strong reason. Except perhaps in some
messages about politics, posted through my personal account @mts.net
on local wpg.* (Winnipeg) newsgroups.


--
Al Balmer
Balmer Consulting
re************************@att.net
Nov 14 '05 #16
Walter Roberson <ro******@ibd.nrc-cnrc.gc.ca> spoke thus:
Alan, my quoting style is there to make quotes -easier- to read
for humans. My quoting style uses a different character for
each indentation level, so that humans can tell which quote is which
at a glance. Humans are very good at pattern matching with distinct
characters, but not nearly as good at mentally counting rows of
repetitions of the same character once the count gets beyond
about 4.


You and Mr. Falconer could apparently both benefit from better
newsreaders. As I noted elsewhere, my newsreader correctly identifies
your ':' delimiter as a quote character, but it also highlights up to
three levels of quoted text in different colors, rendering your point
of concern moot.

In any case, I would take a long look at any practice that would
prevent me from receiving advice from someone of Mr. Falconer's
extensive experience, but of course that's your perogative.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #17
In article <g8********************************@4ax.com>,
Alan Balmer <al******@spamcop.net> wrote:
:On 22 Mar 2005 18:00:21 GMT, ro******@ibd.nrc-cnrc.gc.ca (Walter
:Roberson) wrote:

:>My quoting style uses a different character for
:>each indentation level, so that humans can tell which quote is which
:>at a glance.

:Counting is not necessary. As you say, humans are very good at
:patterns, and in this case, the pattern is the consistent indentation
:and character, visible at a glance.

If one mixes quotes of (say) level 6 and 7 in the text, using a
consistant '>' leader character, then unless said quotes are adjacent
to each other, humans cannot immediately tell which is which. Humans
are -not- good at detecting consistant indentation levels that only
differ by one character (but find it easier if the identation per level
is greater.)

Have you not, while coding, found yourself moving forward one line at a
time, staying in the same column, in order to verify that all your
indentation levels match up properly? Visual memory of indentations is
rapidly lost after a small number of lines, particularily once the part
to be matched is no longer visible on the screen. A unique character
per level is easier to recognize unless one can make the indentation
levels markedly different.
:With varying characters, of
:varying widths, that pattern recognition is useless, and analysis of
:the levels requires just that, analysis.

No, it just requires a glance at the character immediately proceeding
the quoted text to tell whether it is the same level or not.

:I see. So you're inflicting this on all of us just to spite CBF.

No, I have used the same quoting style for many years.
--
I was very young in those days, but I was also rather dim.
-- Christopher Priest
Nov 14 '05 #18

"Walter Roberson" <ro******@ibd.nrc-cnrc.gc.ca> wrote in message
news:d1**********@canopus.cc.umanitoba.ca...
In article <8g********************************@4ax.com>,
Alan Balmer <al******@spamcop.net> wrote:
:On 22 Mar 2005 08:58:22 GMT, ro******@ibd.nrc-cnrc.gc.ca (Walter
:Roberson) wrote:
:>Nonsense. My posts meet all RFC requirements. If your
:>newsreader messes them up then that's your problem.

:It's not nonsense - it makes your replies hard to read, especially
:when mixing quotes from others who use the conventional quote marking.

Alan, my quoting style is there to make quotes -easier- to read
for humans. My quoting style ...blah blah blah....

You don't actually work with customers in your job do you? If my customers
kept telling me over and over again that the user interface I designed was
difficult to read and understand, and I kept telling them "no it's not, it's
designed to be easier to read for humans", I'd be fired in a second!

Think about the logic of what you're saying. You have a bunch of readers,
who are all humans, telling you it is more *difficult* to read your quotes
and you keep saying it's *easier* for humans to read.

Well anyway, I hope you get a little enjoyment out of being a rebel in a
newsgroup. You gotta live for something in life I guess.
Dan

Nov 14 '05 #19
In article <uP********************@twister.southeast.rr.com >,
Dan P. <dp***************@ec.rr.com> wrote:
:If my customers
:kept telling me over and over again that the user interface I designed was
:difficult to read and understand, and I kept telling them "no it's not, it's
:designed to be easier to read for humans", I'd be fired in a second!

Am I to understand, then, that if your "customers" kept telling you
over and over again that your rigid categorization of certain ideas was
difficult to use, that you would refrain from saying "No it's not, it's
designed to be easier!" ?

And yet that's precisely what happens over and over again with people
who come into clc looking for information and instead are given the
bum's rush: when they question why, they are told that the narrow focus
and squelching of those who would attempt to help, is designed to be
"easier".

Many many people have told the regulars that there is something wrong
with the way clc is usually run, but dissent is handled with an
attitude of "We know what's good for you!", with a definite flavour of
"Thou shalt do what is convenient for the newsgroup regulars, or else
their devine technical radiance shalt be withheld from thou."
I'm not saying, Dan, that your point in this regard is not an
interesting one; I am, though, saying that the principle you raise is
being overlooked when it comes to other aspects of the newsgroup.
I would also point out, Dan, that trimming what someone has
written and inserting "blah blah blah" is not an approach which
tends to convince others that you are making reasoned statements.
There is a difference between disagreeing with someone's conclusions
and being dismissive of the arguments in a way that suggests that
one did not even read the arguments.
--
Walter Roberson is my name,
And Usenet is my nation.
Cyber space is my dwelling pace,
And flames my destination.
Nov 14 '05 #20
ro******@ibd.nrc-cnrc.gc.ca (Walter Roberson) writes:
[...]
If it were Chris or Keith making the request, then I would give their
points serious consideration, as it appears to me that both of those
gentlemen are more interested in helping people than they are in
controlling others.


Ok, here I am. Flattery will get you nowhere, but it's certainly
worth a try. 8-)}

Personally, I don't find your use of ':' for quotations to be a major
problem (for me; I don't speak for anyone else), but neither do I find
it at all helpful. I do find that the lack of a blank between the ':'
and the quoted text makes it more difficult to read; I have the same
problem with a '>' prefix not followed by a blank.

I sometimes use a ']' prefix to indicate that I'm quoting from
something other than a previous article in the thread. It's visually
similar enough to '>' that it looks like a quotation, but different
enough to serve as a marker that something interesting is going on.

For example, I might do something like (additionally meta-quoting by
indentation):

In another newsgroup a few months ago, so-and-so said something
that seems relevant to this discussion:
] Blah blah blah.
] Yadda yadda yadda.

The fact that a block of text is quoted from something other than the
current thread is interesting enough that it's worth calling attention
to it. The fact that a block of text is being quoted by Walter
Roberson isn't. (Nothing personal; the fact that a block of text is
being quoted by Keith Thompson isn't particularly interesting either.)

As for making it easier to read text that's quoted many levels deep,
I'm unconvinced. Very deep quotation is often a sign that somebody
didn't trim enough irrelevant text. And since there's no generally
accepted convention to use ':' in such cases, the only information it
conveys is that Walter Roberson is in the discussion (see above).

A number of people have said that they find the ':' prefix makes your
articles more difficult to read. Many have done so politely. I see
no reason to doubt them. I haven't seen anyone say that it makes them
easier to read. I take your word for it that your intent was greater
readability. Either you've been unsuccessful, or there's a silent
majority out there that disagrees with you.

I understand the temptation to dig in your heels when you think
someone is being rude. That creates a quandary when someone rudely
gives you good advice. (I'm not commenting on whether anyone actually
is being rude here.)

I'm reminded of the 8th of Henry Spencer's 10 Commandments for C
Programmers <http://www.plethora.net/~seebs/c/10com.html>:

Thou shalt make thy program's purpose and structure clear to thy
fellow man by using the One True Brace Style, even if thou likest
it not, for thy creativity is better used in solving problems than
in creating beautiful new impediments to understanding.

For the One True Brace Style, substitute the "> " quotation prefix.
Conformity in the little things is often a good thing.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #21
On Mon, 21 Mar 2005 22:52:37 -0500, "nkhan" <nk***@memphis.edu> wrote:
Need some help on this please:
EECE1207 Spring 2005

Computer Assignment # 1
Due Wednesday, March 23rd

The file ‘grades.txt’, as shown below, contains the results of a
true-false exam given to a group of students. You may assume that the
number of students will always be less than 20. The first line contains
the key answer representing the 10 correct answers. Starting from the
second line, each line of the data file contains the student
identification number and the student’s answer to 10 true-false
questions.
Write a program that reads as input the file ‘grades.txt’. The program
should start by readng the correct answer from the first line into a 1-D
character array named correct_answers, then do the following tasks:
Read the students ID numbers into a 1-D integer array named ID, and read
each student’s answers into a 1-D character array containing the answers
for the current student, named current_answers. The number of students,
num_students, should be determined in the process.
While reading the data in (1), compute and store the number of correct
answers for each student in a 1-D integer array named scores.
After reading all the data, determine the average score, AvgScore.
Finally, print a three-column table on the screen that displays the ID
number, the score, and the grade (Pass or Fail) for each student.

The grades should be determined as follows: If the score is larger than
AvgScore then the grade is Pass; otherwise the grade is Fail.

Contents of the file ‘grades.txt’:

FTFFTFFTFT
1080 FTTFTFTTFT
1340 FTFTFTTTFF
1341 FTTFTTTTTT
1401 TTFFTFFTTT
1462 TTFTTTFFTF
1464 FTFFTFFTFF
1465 TTTTTTTTTT
1466 FFFFFFFFFF
1467 FTFTFFTFTF
1468 FFTTFFTTFF
1469 TTTTTFFFFF
1470 FFFFFTTTTT

Note:
Your program must be written so that it could process a file with any
number of students.
Go back and ask your instructor how any number of students can be
assumed to be less than 20.
Adequate comments should be placed throughout your program to briefly
describe it statements.

This is what I have so far:


#include<stdio.h>
AvgScore(int score[],int i){
int total;
int avg;
int j;
for(total = 0, j = 0; j < i; i++)
j starts out as 0. i is probably positive. When do you think the
loop will terminate? Did you mean j++?
{
total += score[i];
}
avg = total/i;
return avg;
}
int main (void)
{
#define NUMSTUDENTS 20
#define NUMANSWERS 10
int ID[NUMSTUDENTS];
char correct_answers[NUMANSWERS+2];
char current_answers[NUMANSWERS+2];
int i=0;
int score[NUMSTUDENTS];
char *ptr1, *ptr2;
int avg;
FILE* fpi=fopen("grades.txt", "r");
Opening a file should always be checked for success.


//read correct answers
fscanf(fpi,"%s",&correct_answers);
A couple of problems here:

%s requires that the corresponding argument have type pointer to
char. Yours does not. It has type pointer to array of 12 char. This
leads to undefined behavior.

Your instructor did not promise there would be only white space
after the 10 answers. If there are any additional characters, you
will overflow correct_answers and again invoke undefined behavior.
//check for valid file
if(!fpi) printf("Did not open file");
Too late, you already tried to read from the file. Move this
immediately following the fopen.

Now that you know the file did not open, why are you continuing to
attempt to process what you think is the following data?

while( !feof(fpi) ){
feof does not tell you are about to read beyond the end of the file.
It only tells after you have already attempted to do so.
// read student-id
fscanf(fpi,"%d", &ID[i]);
// read answers
fscanf(fpi,"%s",current_answers);
i++;
// process data not shown
//i= num of students
}
fclose(fpi);

score[NUMSTUDENTS] = 0;
How many elements are there in score? What is the index of the first
one? The last one?
ptr1 = &correct_answers[0];
ptr2 = &current_answers[0];
for (i = 0; i < 10; i++){
How many students are you attempting to process?
if (*ptr1++ == *ptr2++)
score[i]++;
What is the value of score[0] just prior to executing this statement?
Where was it initialized? How often will score[0] be incremented if
student 0 answers every question correctly?
}
avg=AvgScore(score,i);
What is the value of i at this point? How does it relate to the
number of students?

printf("%d\n",ID[i]);
Given the value of i, how do you know that ID[i] contains a valid
value?
printf("%d\n",score[i]);

for (score[i];score[i]<avg;score[i]++){
After going through all the trouble to calculate score[i] based on the
students' answers and the answer sheet, why would you then increment
score[i] and render its value meaningless?
printf("Fail");}
for (score[i];score[i]>avg;score[i]++){
The previous for loop will stop when score[i] equals or exceeds avg.
If equal, this loop will never execute. If greater than, this loop
will never terminate.
printf("Pass");}

return 0;

}
I keep getting a steam!=null error upon trying to execute the file, the
compiler shows no errors or warnings however. Any help would be greatly
appreciated. Thank you.


<<Remove the del for email>>
Nov 14 '05 #22
Barry Schwarz wrote:

On Mon, 21 Mar 2005 22:52:37 -0500, "nkhan" <nk***@memphis.edu> wrote:
Need some help on this please:
EECE1207 Spring 2005

Computer Assignment # 1
Due Wednesday, March 23rd

The file ‘grades.txt’, as shown below, contains the results of a
true-false exam given to a group of students. You may assume that the
number of students will always be less than 20. The first line contains
the key answer representing the 10 correct answers. Starting from the
second line, each line of the data file contains the student
identification number and the student’s answer to 10 true-false
questions.
Write a program that reads as input the file ‘grades.txt’. The program
should start by readng the correct answer from the first line into a 1-D
character array named correct_answers, then do the following tasks:
Read the students ID numbers into a 1-D integer array named ID, and read
each student’s answers into a 1-D character array containing the answers
for the current student, named current_answers. The number of students,
num_students, should be determined in the process.
While reading the data in (1), compute and store the number of correct
answers for each student in a 1-D integer array named scores.
After reading all the data, determine the average score, AvgScore.
Finally, print a three-column table on the screen that displays the ID
number, the score, and the grade (Pass or Fail) for each student.

The grades should be determined as follows: If the score is larger than
AvgScore then the grade is Pass; otherwise the grade is Fail.

Contents of the file ‘grades.txt’:

FTFFTFFTFT
1080 FTTFTFTTFT
1340 FTFTFTTTFF
1341 FTTFTTTTTT
1401 TTFFTFFTTT
1462 TTFTTTFFTF
1464 FTFFTFFTFF
1465 TTTTTTTTTT
1466 FFFFFFFFFF
1467 FTFTFFTFTF
1468 FFTTFFTTFF
1469 TTTTTFFFFF
1470 FFFFFTTTTT

Note:
Your program must be written so that it could process a file with any
number of students.


Go back and ask your instructor how any number of students can be
assumed to be less than 20.


The program is intended to be written so as to be able
to handle more than the amount of available students.
I think a linked list is called for.
I like the assignment but there wasn't enough time given.

--
pete
Nov 14 '05 #23
pete wrote:

Barry Schwarz wrote:
Note:
Your program must be written so that
it could process a file with any
number of students.


Go back and ask your instructor how any number of students can be
assumed to be less than 20.


I think a linked list is called for.


Except that the assignment specifies arrays,
so maybe it's a realloc exercise.

--
pete
Nov 14 '05 #24

"Walter Roberson" <ro******@ibd.nrc-cnrc.gc.ca> wrote in message
news:d1**********@canopus.cc.umanitoba.ca...
In article <uP********************@twister.southeast.rr.com >,
Dan P. <dp***************@ec.rr.com> wrote:
:If my customers
:kept telling me over and over again that the user interface I designed
was
:difficult to read and understand, and I kept telling them "no it's not,
it's
:designed to be easier to read for humans", I'd be fired in a second!

Am I to understand, then, that if your "customers" kept telling you
over and over again that your rigid categorization of certain ideas was
difficult to use, that you would refrain from saying "No it's not, it's
designed to be easier!" ?

And yet that's precisely what happens over and over again with people
who come into clc looking for information and instead are given the
bum's rush: when they question why, they are told that the narrow focus
and squelching of those who would attempt to help, is designed to be
"easier".

Many many people have told the regulars that there is something wrong
with the way clc is usually run, but dissent is handled with an
attitude of "We know what's good for you!", with a definite flavour of
"Thou shalt do what is convenient for the newsgroup regulars, or else
their devine technical radiance shalt be withheld from thou."
I'm not saying, Dan, that your point in this regard is not an
interesting one; I am, though, saying that the principle you raise is
being overlooked when it comes to other aspects of the newsgroup.
I would also point out, Dan, that trimming what someone has
written and inserting "blah blah blah" is not an approach which
tends to convince others that you are making reasoned statements.
There is a difference between disagreeing with someone's conclusions
and being dismissive of the arguments in a way that suggests that
one did not even read the arguments.
--

After reading all that, I'm pretty sure you're just trying to be a
rebel/troll now. So I'm done debating about the quote character, because
that's all I was talking about.

Dan
Nov 14 '05 #25
"Walter Roberson" <ro******@ibd.nrc-cnrc.gc.ca> wrote in message
news:d1**********@canopus.cc.umanitoba.ca...
In article <8g********************************@4ax.com>,
Alan Balmer <al******@spamcop.net> wrote:
:On 22 Mar 2005 08:58:22 GMT, ro******@ibd.nrc-cnrc.gc.ca (Walter
:Roberson) wrote:
:>Nonsense. My posts meet all RFC requirements. If your
:>newsreader messes them up then that's your problem.

:It's not nonsense - it makes your replies hard to read, especially
:when mixing quotes from others who use the conventional quote marking.

Alan, my quoting style is there to make quotes -easier- to read
for humans.
It doesn't, because a colon will appear as _two pixels_ on many readers'
screens. Add onto that your quoting style doesn't put a space between the
colon and the quote, and it's very difficult to tell the text is quoted at
all. One might think it's a typo or even miss the colon entirely.

I don't mind characters other than > used for quoting, but _please_ pick
ones that are more easily detectable than :.
My quoting style uses a different character for
each indentation level, so that humans can tell which quote is which
at a glance. Humans are very good at pattern matching with distinct
characters, but not nearly as good at mentally counting rows of
repetitions of the same character once the count gets beyond
about 4.


Word wrap is the far bigger issue when quoting goes beyond three or four
levels; the correct solution on Usenet is to not require quoting that
deeply. In the rare event that so much context is needed, one can always
replace the text with a short summary in []s.

S

--
Stephen Sprunk "Stupid people surround themselves with smart
CCIE #3723 people. Smart people surround themselves with
K5SSS smart people who disagree with them." --Aaron Sorkin

Nov 14 '05 #26
Stephen Sprunk wrote:
.... snip ...
Word wrap is the far bigger issue when quoting goes beyond three or
four levels; the correct solution on Usenet is to not require
quoting that deeply. In the rare event that so much context is
needed, one can always replace the text with a short summary in []s.


Two simple expedients keep that under control. First, the original
should wrap at something like 65 chars. Second, the newsreader
should detect quoted lines, and not rewrap them. A third, less
critical, expedient is to not add blanks between '>' quote chars.
All of this requires agreement about what the quote character
actually is, and the defacto standard is '>'.

This allows quoting to disgusting depths on almost any system,
including those with 80 char line limitations. This is no excuse
for failure to snip irrelevant material.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Nov 14 '05 #27
On 22 Mar 2005 08:58:22 GMT, in comp.lang.c , ro******@ibd.nrc-cnrc.gc.ca
(Walter Roberson) wrote:
Nonsense. My posts meet all RFC requirements. If your
newsreader messes them up then that's your problem.


yeah, lets not start that again. Your quotation style is unusual and nonstandard
with a small ess. If you don't agree, provide stats to back you up, taken from
the entire of usenet. FWIW I think its a daft reason to plonk you

But that doesn't invalidate CBF's point which was that the OP snipped all
context and left a meaningless post.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
Nov 14 '05 #28
On 22 Mar 2005 18:00:21 GMT, in comp.lang.c , ro******@ibd.nrc-cnrc.gc.ca
(Walter Roberson) wrote:
Alan, my quoting style is there to make quotes -easier- to read
for humans.
Yeah, well, let me be amongst the many to point out that ITS NOT WORKING.
You';re making it harder. So please stop,
My quoting style uses a different character for
each indentation level, so that humans can tell which quote is which
at a glance.
Thats nonsensical. Your scheme forces me to remember what style is used for each
level. How can that be easier than following a well-established custom that
people have successfully used for 25 years and even newbies are familiar with?
:Why do you take such delight in causing a problem? What's the gain?
<snip non-answer>

would you care to answer the question next time?
Someone has to take a stand, and though it is certainly not my usual
position to do so, it seems to have fallen onto me in this situation.
Whoopy doo. Now I'm starting to consider plonking you too, for being a pompous
ass.
If anyone happens to be curious as to whether provocation is my usual
style,


Nope. However pomposity seems to be .

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
Nov 14 '05 #29
On 22 Mar 2005 18:33:13 GMT, in comp.lang.c , ro******@ibd.nrc-cnrc.gc.ca
(Walter Roberson) wrote:
In article <42***************@yahoo.com>,
CBFalconer <cb********@worldnet.att.net> wrote:
:As you can see he is too full of his own self-importance.

No, but I am too empty of the self-importance of certain other people.
so why /do/ you insist in using a nonstandard quote char? I'm assuming its not
simply that you have a crapola newsreader thats hard to configure, if so, I
concede the point.
:the only cure is to persuade everybody to PLONK him, and then maybe
:he will go away.
well, thats a solution tho IMHO the crime hardly merits the punishment.
A major premise by which certain people attempt to control the
newsgroup is that there are too many newcomers who don't know what
the current clique rules are about what is acceptable


Euh, using > for quotations is NOT a clique rule. Get a clue.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
Nov 14 '05 #30
On 22 Mar 2005 19:52:02 GMT, in comp.lang.c , ro******@ibd.nrc-cnrc.gc.ca
(Walter Roberson) wrote:
If one mixes quotes of (say) level 6 and 7 in the text, using a
consistant '>' leader character, then unless said quotes are adjacent
to each other, humans cannot immediately tell which is which.
Yes they can. If you have evidence to the contrary, produce it.

Your arguments remind me of politicans trying to sell us an idea that benefits
only the state and security ser, by telling us it'll make us safer, richer or
happier. Its snake oil, and no amount of grinning islingtonians will convince me
otherwise.

Humans
are -not- good at detecting consistant indentation levels that only
differ by one character (but find it easier if the identation per level
is greater.)
You are incorrect, and 25 years of empiricial evidence supports that suggestion.
Have you not, while coding, found yourself moving forward one line at a
time, staying in the same column, in order to verify that all your
indentation levels match up properly?


Yes. However in code, we don't fill each line with braces. If we did, it'd be
easy as the eye is very good at spotting patterns of that kind.
if (x>3) {
{{{{ x +=5;
}
else
{
{{{{do{
{{{{{{{{for(i=3;i<12;i++){
{{{{{{{{{{{{x+=i;
}}}}}}}}
}}}}
}

:-)
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
Nov 14 '05 #31
Mark McIntyre <ma**********@spamcop.net> writes:
On 22 Mar 2005 08:58:22 GMT, in comp.lang.c , ro******@ibd.nrc-cnrc.gc.ca
(Walter Roberson) wrote:
Nonsense. My posts meet all RFC requirements. If your
newsreader messes them up then that's your problem.


yeah, lets not start that again. Your quotation style is unusual and nonstandard
with a small ess. If you don't agree, provide stats to back you up, taken from
the entire of usenet. FWIW I think its a daft reason to plonk you


Um, Mark, if you're going to discuss posting styles, it might be good
to keep your lines well below 80 columns.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #32
On Thu, 24 Mar 2005 00:13:15 GMT, in comp.lang.c , Keith Thompson
<ks***@mib.org> wrote:
Mark McIntyre <ma**********@spamcop.net> writes:
On 22 Mar 2005 08:58:22 GMT, in comp.lang.c , ro******@ibd.nrc-cnrc.gc.ca
(Walter Roberson) wrote:
Nonsense. My posts meet all RFC requirements. If your
newsreader messes them up then that's your problem.


yeah, lets not start that again. Your quotation style is unusual and nonstandard
with a small ess. If you don't agree, provide stats to back you up, taken from
the entire of usenet. FWIW I think its a daft reason to plonk you


Um, Mark, if you're going to discuss posting styles, it might be good
to keep your lines well below 80 columns.


sorry, I widened it to 80 in order to read some damn thread with about
a zillion levels of quotations, and never got round to narrowing it
again. Is this better?
:-)
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Nov 14 '05 #33
Mark McIntyre wrote:
(Walter Roberson) wrote:
CBFalconer <cb********@worldnet.att.net> wrote:

.... snip ...
so why /do/ you insist in using a nonstandard quote char? I'm
assuming its not simply that you have a crapola newsreader thats
hard to configure, if so, I concede the point.
: the only cure is to persuade everybody to PLONK him, and then
: maybe he will go away.


well, thats a solution tho IMHO the crime hardly merits the
punishment.
A major premise by which certain people attempt to control the
newsgroup is that there are too many newcomers who don't know
what the current clique rules are about what is acceptable


Euh, using > for quotations is NOT a clique rule. Get a clue.


I think you are gradually getting the flavor that led to a PLONK.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
Nov 14 '05 #34

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by pruebauno | last post: by
11 posts views Thread by Arturo DiDonna | last post: by
1 post views Thread by Jim Heavey | last post: by
6 posts views Thread by Josefo | last post: by
8 posts views Thread by WebSnozz | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.