C++ code questions
does anyone know the code for writing a C++ function that counts characters, number of lines and number of bytes in a file?
[123 byte] By [
masterb] at [2007-11-11 7:18:31]

# 1 Re: C++ code questions
standard C++ doesn't have such a function but you can write it rather easily. Use the <cctype> (or <ctype.h> in C) library to classify bytes into characters (use isalpah() for this), digits (isdigit() ), isspace() for blanks etc. Then sum up all the results. This should be the total number of bytes in the file. Of course, you will need to use the <fstream> or <stdio.h> libraries to open the file and read from it.
Danny at 2007-11-11 21:02:24 >

# 2 Re: C++ code questions
seek and tell will get you the size(bytes) of smaller files (up to unsigned int size?)
the rest you will have to parse out.
jonnin at 2007-11-11 21:03:30 >
