- #1
- 74
- 0
Homework Statement
What is the difference between these two functions?
Can you write down an example of each?AllenHe said:But I don't know the difference between these two
int dec = <some integer>;
int bin[8];
int i;
for (i = 0; i < 8; i++) {
bin[i] = dec%2;
dec /= 2;
}
FILE *fp;
fp = fopen(<some file>);
int c = getc(fp); //initialize c as the first character in the input file
while (c != EOF) { //Keep the loop going until c == EOF (end-of-file).
putchar(c); //print whatever c is, as a character (c is considered an int, but it has a char representation).
c = getc(fp); //set c as the next character in the file
}
FILE *fp;
fp = fopen(<some file>);
int c = 0;
do {
c = getc(fp);
putchar(c);
} while (c != EOF);