I am just learning c language at the moment, i have problem with following program:
#define TRUE 1
#define FALSE 0
#define MAX_LENGTH 100000 /* Max number of chars read from file */
#include <stdio.h>
#include <ctype.h>
int Get_String_From_File(char filename[], char input[])
/* Reads in characters (including \n) from a file as one long string */
/* filename should give name of an existing file;
input will return contents of that file */
/* Return value 0 if file open fails, 1 otherwise */
/* Maximum length of string is stored in MAX_LENGTH */
{
int i = -1; /* will be updated before being used */
char temp;
FILE *infile;
infile = fopen(filename,"r");
if (infile == NULL) {
printf("Failed to open file \"%s\"\n",filename);
return FALSE;
}
do {
i++;
input[i] = fgetc(infile);
} while (input[i] != EOF && i < MAX_LENGTH - 1 && input[i] != '\0');
if (i == MAX_LENGTH - 1) /* only reason for stopping is MAX_LENGTH */
fprintf(stderr,"Warning: Reached maximum size of file handled by this program!\n\n");
input[i] = '\0'; /* end of string marker*/
fclose(infile);
return TRUE; /* Successfully read file */
}
int main(void)
{
int c, i, j, letter[26][26];
for (i=0; i<26; ++i) /* init array to zero */
letter[i] = 0;
for( j= 0; j<26; ++j)
letter[j] = 0;
while((c = getchar()) != EOF) /* count the letter */
if(isupper(c) && islower(c))
++letter[c -> 'A' && c -> 'a'];
for (i=0; i<26; ++i)
if(i%6==0)
for ( j= 0; j<26; ++j)
if(j%6==0) {
printf("\n");
printf("%4c%4c:%3d%3d", 'A' || 'a' +i +j, letter[i][j]);
}
printf("\n\n");
return 0;
}