473,396 Members | 1,907 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,396 software developers and data experts.

Need help with C program

I am a programmer (cobol, peoplesoft, sqr, etc.) so I am familiar
with programming logic, etc. but not very familiar with C. I need a C
program in a study I'm doing. The program is fairly simple, but not
familiar with C code it would take me some time to get it to work. A
good C programmer can probably give me the code in a few minutes.

Here's the program specs:

I'm doing a study on the italicized words in the King James Bible. The
italicized words are words not in the Greek and Hebrew text but were
added by the translators for sentence structure, etc.

I have a text file of the Old Testament and the New Testament. The
italicized words are surrounded by brackets []. If a verse contains
any italicized words I want to write that verse to a new flat-file
that I will use in Word to look at, get counts, and do some grammar
statistics, etc.

Here's a sample of the input flat-file with a few verses from Genesis.
Notice verses 2, 4, and 7 contain italicized words or brackets.

1 In the beginning God created the heaven and the earth.
2 And the earth was without form, and void; and darkness [was] upon
the face of the deep. And the Spirit of God moved upon the face of the
waters.
3 And God said, Let there be light: and there was light.
4 And God saw the light, that [it was] good: and God divided the light
from the darkness.
5 And God called the light Day, and the darkness he called Night. And
the evening and the morning were the first day.
6 And God said, Let there be a firmament in the midst of the waters,
and let it divide the waters from the waters.
7 And God made the firmament, and divided the waters which [were]
under the firmament from the waters which [were] above the firmament:
and it was so.
8 And God called the firmament Heaven. And the evening and the morning
were the second day.

So my output file would look like

2 And the earth was without form, and void; and darkness [was] upon
the face of the deep. And the Spirit of God moved upon the face of the
waters.
4 And God saw the light, that [it was] good: and God divided the light
from the darkness.
7 And God made the firmament, and divided the waters which [were]
under the firmament from the waters which [were] above the firmament:
and it was so.

The logic I came up with would be something like:

Read a character from the flat-file:
Check for a number
If number (indicates a new verse)
If a "[" is found (found_flag) from previous verse
write the WORK AREA stored verse to the output file.
Possibly need to write an eol character
Clear out the work area
Clear out the found [ flag

If a [ is NOT found (found-flag) then
clear the stored verse

Move each character to a WORK AREA
Check each character for a "["
If found set the found_flag = y

Got get another character

Another variation I would like to do is create an output file of JUST
the italicized words or bracketed words.

A couple of questions or issues:

How large a file can C read?
The Old Testament file is 3,282,275 characters (size is 3,342,336
bytes) If needed I could cut up the files.

Is there a better way?

I will probably use Borland C+ as the compiler.

If possible, please email any solutions to tw******@charter.net

Thank you very much for your time and expertise.
Jul 19 '05 #1
1 1628

This question is off topic for comp.lang.c++ - comp.object or
comp.programming would be better.

terry wrote:
..... big snip

Is there a better way?
Yes. If this is all you want to do, a database (like PostgreSQL) would
manage this in a one liner.

Or even better, "grep '\\[' bible.txt" does the job.

I will probably use Borland C+ as the compiler.

If possible, please email any solutions to tw******@charter.net

Thank you very much for your time and expertise.


Most modern computers can read 5 or six bibles into "memory" without
breaking a sweat.

Before I could reccomend a class design, I'd need to know much more
about the kinds of things that you want to do.

Here is a stab in the dark.

class Verse
{
public:

std::string m_verse;

bool HasItalics();
};

class Bible
{
public:

std::list<Verse> m_verses;
};
int main()
{

Bible b;

ReadBible( b );

std::list<Verse> italicslist;

std::list<Verse>::iterator i_end = b.m_verses.end();

for (
std::list<Verse>::iterator i = b.m_verses.begin();
i != i_end;
i ++
) {
if ( i->HasItalics() ) {
italicslist.insert( *i );
}
}

WriteVerses( italicslist );

}

It probably makes a few copies of objects it need not do but before we
go optimize anything you need to have a few more requirements nailed down.

.... not very useful yet.

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Spamtrap | last post by:
I only do occasional Perl programming and most things I write are short processes. I have something I'm working on that is scanning a text file with about 15 million lines and trying to extract...
2
by: aj902 | last post by:
Hello , I am trying to create a program where all detail, http://www.albany.edu/~csi333/projects.htm
13
by: vgame64 | last post by:
Hi, I have been struggling with writing a program for a few hours. The requirements are that: """You will be writing a program which will determine whether a date is valid in terms of days in that...
4
by: robinsand | last post by:
My apologies to those of you who are more advanced Visual C++ .NET programmers, but I am working on a project for an MBA course that is condensed into an eight-week schedule, and I need help...
16
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client...
8
by: skumar434 | last post by:
i need to store the data from a data base in to structure .............the problem is like this ....suppose there is a data base which stores the sequence no and item type etc ...but i need only...
4
by: naknak4 | last post by:
Introduction This assignment requires you to develop solutions to the given problem using several different approaches (which actually involves using three different STL containers). You will...
6
by: naknak | last post by:
Introduction This assignment requires you to develop solutions to the given problem using several different approaches (which actually involves using three different STL containers). You will...
1
by: peterggmss | last post by:
This is a slot machine game, 2 forms. One is the actual game (frmMachine) and the other is in the background and randomizes the images shown on frmMachine. I need to make frmMachine wait for...
1
by: raghavshastri | last post by:
You are to write a C++ program to perform a statistical analysis of the blobs in an image. The image will be a grayscale image in PGM format for simplicity. Here is a sample PGM image with 10...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.