hi,
i want to know how to count the no of character which are present in the into a file?
hi,
i want to know how to count the no of character which are present in the into a file?
i don’t know of any direct method of determining the number of characters in a text file (for example, binding to the file and then looking at some sort of Number Of Characters property).
Code:Const ForReading = 1 Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile("C:\Scripts\Test.txt", ForReading) strCharacters = objFile.ReadAll strCharacters = Replace(strCharacters, vbCrLf, "") Wscript.Echo Len(strCharacters) objFile.Close
#include <stdio.h>i want to know how to count the no of character which are present in the into a file?
#include <stdlib.h>
const char FILE_NAME[] = "input.txt";
int main()
{
int count = 0;
FILE *in_file;
int ch;
in_file = fopen(FILE_NAME, "r");
if (in_file == NULL)
{
printf("Cannot open %s\n", FILE_NAME);
exit(8);
}
while (1)
{
ch = fgetc(in_file);
if (ch == EOF)
break;
++count;
}
printf("Number of characters in %s is %d\n",
FILE_NAME, count);
fclose(in_file);
return (0);
}
Bookmarks