compiling error

W

Walter Roberson

: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.
 
B

Barry Schwarz

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;
}
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);
// 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++;


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);


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

for (score;score<avg;score++){


After going through all the trouble to calculate score based on the
students' answers and the answer sheet, why would you then increment
score and render its value meaningless?
printf("Fail");}


for (score;score>avg;score++){


The previous for loop will stop when score 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>>
 
P

pete

Barry said:
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.
 
D

Dan P.

Walter Roberson said:
: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
 
S

Stephen Sprunk

Walter Roberson said:
:On 22 Mar 2005 08:58:22 GMT, (e-mail address removed)-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
 
C

CBFalconer

Stephen said:
.... 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.
 
M

Mark McIntyre

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.
 
M

Mark McIntyre

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 .
 
M

Mark McIntyre

: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.
 
M

Mark McIntyre

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;
}}}}}}}}
}}}}
}

:)
 
K

Keith Thompson

Mark McIntyre said:
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.
 
M

Mark McIntyre

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?
:)
 
C

CBFalconer

Mark said:
.... 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.


well, thats a solution tho IMHO the crime hardly merits the
punishment.


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.
 

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

No members online now.

Forum statistics

Threads
474,161
Messages
2,570,892
Members
47,427
Latest member
HildredDic

Latest Threads

Top