This is an occasional misconception in programming languages... awk does not have a "print number of fields in end block" piece of code, that'd be an oddly specific thing to have. You'd have to find two separate, independent things in awk's source code:
1) Whatever sets the NF special variable.
2) Whatever causes the END code block to be run.
There are many ways to do it in C, but you almost certainly wouldn't be doing it the way awk does it, which can be quite complex -- some versions of awk let you use a regex for the field separator...
One way:
char fs=' ';
const char *p="a b c d e";
int nf=0;
// Keep looping until you can't find fs
while(p=strchr(p, fs)) nf++;
printf("nf=%d\n", nf);
thank you..so much dear...I added end block so that it will print only one value rather than printing NF of each line..
once again thank you..for explanation..
Actually, it does not (necessarily). If NF is still defined in the END section - which is not guaranteed in all awk versions - it will print the number of fields in the last line/row of the last file in the input stream. This may be different from No. of cols in other lines / other files!
This comment may seem nit picking, but I made it to prevent misconception of how awk works.