ANSWERS: 2
-
I won't do your homework for you especially on something this easy but to get you started you probably want to use stdlib.h use the argc and argv in main to pass a file name in so you don't hard code the name or just use standard input to read from so you can redirect the file name into your code. Use fopen() to open the file (if you choose to open a file rather than redirect from the already open stdin, see getchar()) and then a loop with a counter and use one of the getchar() variants to fetch from the file a byte at a time while incrementing the counter for size. Use a printf to output the size when you're done. That should make it pretty easy for you.
-
#include <stdio.h> #include <iostream.h> #include <Windows.h> void main() { WIN32_FIND_DATA wfd; HANDLE h; h=FindFirstFile("C:\Numbers.txt", &wfd); cout << wfd.nFileSizeHigh << " - " << wfd.nFileSizeLow << " - " << h << endl; getchar(); }
Copyright 2023, Wired Ivy, LLC

by 