473,402 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

counting letters and sequence

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;
}
Oct 25 '06 #1
2 2114
vermarajeev
180 100+
Please let us know what is the problem.

Thankx
Oct 25 '06 #2
the problem is to count the letters and sequence from a file. the fist thing of my code is to read file and in the main function i create is to count the characters and sequence by using 2 dimension array.
where the character include letters and spaces.
Oct 26 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Mike Dee | last post by:
A very very basic UTF-8 question that's driving me nuts: If I have this in the beginning of my Python script in Linux: #!/usr/bin/env python # -*- coding: UTF-8 -*- should I - or should I...
2
by: SunMan | last post by:
Hello! I am trying to create a program that will ask for a user to enter a series of letters (codes) and then print out a table that shows the codes in decending frequency. Only letters will be...
3
by: mark | last post by:
hi guys i need hlp on a c programcounting letters,words,etc .simple. thanks
0
by: euniceno1 | last post by:
the problem is to count the letters and sequence from a file. the fist thing of my code is to read file and in the main function i create is to count the characters and sequence by using 2 dimension...
4
by: bigbagy | last post by:
Notes The programs will be compiled and tested on the machine which runs the Linux operating system. V3.4 of the GNU C/C++ compiler (gcc ,g++) must be used. A significant amount coding is...
3
by: newstips6706 | last post by:
The Art of Counting TIME -------------------------------------------------------------------------------- As the research done on the paper titled: "The Number '1'", which yielded the...
2
by: aboxylica | last post by:
I have a code in which i create a set of alphabets of specified count .Now in particular positions in it i want to embed my choice of letters how do i do it.here is my code def random_seq(): ...
7
by: ccarter45 | last post by:
I need to count the number of letters in a string, disregarding case. It needs to use these two methods. What's wrong? import java.util.Scanner; public class CountLetters { public static void...
10
by: Dmitriy V'jukov | last post by:
On 16 ΝΑΚ, 21:41, "Dmitriy V'jukov" <dvyu...@gmail.comwrote: According to definition, release operation on 'std::atomic_global_fence_compatibility' can only 'synchronize with' acquire...
8
by: xiaolim | last post by:
i making a simple program to count the different kinds of characters in a text file and then display them out, however i only manage to count the total numbers of characters. #include...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.