Can anyone help me with this C++ program?

Can anyone help me how to write this programe in c langugage ? Write a program which can read an arbitrary file (in your program select a file, but we may select other files to test) and will output the number of bytes of the file.

  • Answer:

    #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(); }

joreya at Answerbag.com Visit the source

Was this solution helpful to you?

Other answers

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.

dichosa

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.