Thanks hk_mp5kpdw. I got my answer. here is the final code. Please tell me if there is any scope of improvements.
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main() {
FILE *dataFile;
char fileName[100];
char customer[100];
int nRow = 0, nCol = 0, n=0;
char *line;
char entry[11];
printf("Enter the name of a ascii file: ");
fgets(fileName, sizeof(fileName), stdin);
if((dataFile = fopen(fileName, "r")) == NULL) {
printf("Error Opening File.\n");
exit(1);
}
while((line = fgets(customer, sizeof(customer), dataFile)) != NULL ) {
while(sscanf(line, "%10s%n", entry, &n ) == 1 ) {
nCol++;
line += n;
}
nRow++;
printf("Column Entries: %d Row %d: %s\n",nCol, nRow, customer);
nCol = 0;
}
fclose(dataFile);
return 0;
}
BTW I am using Borland IDE.