#include
#include
int main(void) {
//user information
printf("This programme counts the number of each letter in passage.txt.");
//define file and arrays.
FILE *FileReference;
char Letter[2]= {0}, ArrayOfLetters[128]= {0};
int i=65;
//open file
FileReference=fopen("passage.txt", "r");
if (FileReference == NULL) {
printf("File did not open correctly\n");
return 1;
}
//Loop for capital letters
for (i=65; i<=90; i++) {
while (fgets(Letter,2,stdin) !=0) {
ArrayOfLetters[(Letter[2])]++;
}
}
printf("\n\n%d=%s", ArrayOfLetters, ArrayOfLetters);
return 0;
}
2006-11-27
20:09:46
·
6 answers
·
asked by
sarciness
3
in
Computers & Internet
➔ Programming & Design
Changed stdin to FileReference. Still doesn't work.
2006-11-27
20:15:51 ·
update #1
The program compiles... but does not print the array I'm trying to print. I don't know if Letter is incrementing the array or not.
2006-11-27
20:26:24 ·
update #2
I think my fopen is fine, but I can't actually read what you guys have said as Yahoo! seems to put in ... where I need details!
2006-11-27
20:31:28 ·
update #3
Paul B- I think that's what my program is trying to do- I'm trying to work out why it doesn't.
2006-11-27
20:37:15 ·
update #4