Look at the "wc" command's man page, it will give you a count of all characters, including the newline character.
First of all numbers are not meant to be stored in a string and if u do so in C, these numbers will be treated as characters and you can not perform any calculation on these numbers, and to find the number of characters in a string use the strlen() from the string.h file.
program to extract a given word from a file
#include <stdio.h> #include <conio.h> #include <string.h> #include <process.h> void main(int argc, char *argv[]) { char a[15]; char s[20]; char n; int k; int j=0; int i; int len; FILE *fp; if(argc!=3) { puts("Improper number of arguments."); exit(0); } fp = fopen(argv[1],"r"); if(fp == NULL) { puts("File cannot be opened."); exit(0); } k=*argv[2]-48; n = fread(a,1,k,fp); a[n]='\0'; len=strlen(a); for(i=len-1;i>=0;i--) { s[j]=a[i]; printf("%c",s[j]); j=j+1; } s[j+1]='\0'; getch(); }
Seek to the end of the file (fseek) and check how many bytes are in the file If the byte count is zero the file is empty.
This page website contains list of characters not allowed in a filename on windows, mac, Linux/unix http://www.comentum.com/File-Systems-HFS-FAT-UFS.HTML
wc is the word count utility. wc <file name> would return four values number of lines, number of words, number of characters, filename of the file processed
Use the following:awk 'END { print NR }'Awk will count the lines and print it out.
You don't need a shell script to do this; use the 'grep' command with the '-c' option to count the number of occurrences of some pattern.
First of all numbers are not meant to be stored in a string and if u do so in C, these numbers will be treated as characters and you can not perform any calculation on these numbers, and to find the number of characters in a string use the strlen() from the string.h file.
It can be called a Fixed-Length file.
Wild card
int count_whitespace (FILE* input) { int c, count=0; while (( c = getc(input) ) != EOF ) if ((char) c==' ') ++count; return count; }
a file name can contain any type of character, it can be start from any character,number& can start with symbol also.
Windows 95 supported file names up to 255 characters in length.
count very carefully. . .
Open the file for reading then traverse the file one character at a time. Each time you encounter a character within the range '0' through '9', increment a zero-initialised counter. When you reach the end of the file, close the file and return the counter value. int count_digits (const char* fname) { // Returns -1 on error (test global errno for system-specific errors). FILE* f; int count; char c; // Open file for read-only access (text-mode by default). FILE* f = fopen (fname, "r"); if (f==NULL) return (-1); count = 0; // Read and test each character, incrementing the count whenever the character is a digit. while (fscanf (f, "%d", &c) == 1) if (c>='0' && c<='9') ++count; fclose (f); return count; }
A DOS file, or .bat file can have unlimited characters.