473,396 Members | 2,081 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.

file processing in c

hi all my friends...
ý have a problem with file processing in c... ý have some questions
about it...
ý have two txt files... in first one there is a text, in second one
there are words that ý want to remove these words from first one...
how can ý remove those words from first one?

thx all for ur help

Mar 27 '07 #1
5 2356
On Mar 26, 8:33 pm, "wolky" <hotw...@gmail.comwrote:
hi all my friends...
ý have a problem with file processing in c... ý have some questions
about it...
ý have two txt files... in first one there is a text, in second one
there are words that ý want to remove these words from first one...
how can ý remove those words from first one?

thx all for ur help
You'll have to attempt to solve the problem yourself then come back
and show us your attempt if you want to get help.

Right now I can tell you to look up:
<stdio.h>
fopen
fgets
fclose

You may also want to check out:
<string.h>
strncmp
*or*
strstr

And for something extra:
strstr
<errno.h>
errno

--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)

Mar 27 '07 #2
On Mar 26, 8:58 pm, "Nelu" <tandaui...@gmail.comwrote:
On Mar 26, 8:33 pm, "wolky" <hotw...@gmail.comwrote:
hi all my friends...
<snip>
And for something extra:
strstr
Ooops, I meant: strerror.

--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)
Mar 27 '07 #3
"wolky" <ho*****@gmail.comwrote:
ý have a problem with file processing in c... ý have some questions
about it...
ý have two txt files... in first one there is a text, in second one
there are words that ý want to remove these words from first one...
how can ý remove those words from first one?

Make a third file that is a copy of file 1 without the extraneous words. If
this is not a student exercise you should prepare by organizing the words so
you can find them quite rapidly. You could use a tree or bsearch() which
requires the words be sorted, see qsort(). Both of these are in <stdlib.h>.
Mar 27 '07 #4
On Mon, 26 Mar 2007 17:33:23 -0700, wolky wrote:
hi all my friends...
ı have a problem with file processing in c... ı have some questions
about it...
ı have two txt files... in first one there is a text, in second one
there are words that ı want to remove these words from first one... how
can ı remove those words from first one?
Read the first file, producing an ordered binary tree of structs that
associate each word with its ordinal and any following punctuation.
Note that you must allow for duplicates words in the first file.

Create an ordered binary tree of the words in the second file. Whether
you allow for duplicate words in the second file is between you and
the specification.

Traverse both trees in word order, dropping all members of the first
tree that match words in the second tree.

Create an array of pointers to the remaining entries in the first tree.
Use qsort() to sort them by ordinal number.

Emit the words in the order they appear in the list, each followed by
the associated punctuation. Dealing with orphaned punctuation and
post-punctuation capitalization is left as an exercise for the reader.

thx all for ur help
Even the mesopotamians can't help you now.

Martin
--
Martin Golding | He who steals my code steals trash.
DoD #0236 | (Twas mine, tis his, and will be slave to thousands.)
A poor old decrepit Pick programmer. Sympathize at:
fo*****@comcast.net Vancouver, WA
Mar 28 '07 #5
Martin Golding wrote:
On Mon, 26 Mar 2007 17:33:23 -0700, wolky wrote:
>ı have a problem with file processing in c... ı have some
questions about it... ı have two txt files... in first one
there is a text, in second one there are words that ı want to
remove these words from first one... how can ı remove those
words from first one?

Read the first file, producing an ordered binary tree of structs
that associate each word with its ordinal and any following
punctuation. Note that you must allow for duplicates words in the
first file.
.... snip ...

All that work is already done, using a hashtable rather than a key
(faster), and replacing ids rather than deleting them. Some simple
modifications will satisfy the OPs needs. Note that it is licensed
under the GPL. See id2id-20 in:

<http://cbfalconer.home.att.net/download/>

Arranging for a successful find of change (in filter) and emission
of otherword to replace otherword by the empty string will probably
do it. This is safe because otherword is not involved in the hash
table comparison or hashing routines. Probably take all of 5
minutes to edit, make, and test. This will, of course, foul the
reversing option.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Mar 28 '07 #6

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

Similar topics

0
by: Sure | last post by:
I my php script I call a perl script that perl script will create a log file From the php script I want to read the log file and write the output to the browser. This operation has to carried out...
18
by: Dino | last post by:
dear all, i've created an application for a customer where the customer can upload ..csv-files into a specified ftp-directory. on the server, a php-script, triggered by a cronjob, reads all the...
5
by: matt dittman | last post by:
I have created a windows service that reads emails from a drop directory and moves them to the appropriate mail folder every 15 seconds. I can move, rename and delete the files as needed, up...
8
by: Imran | last post by:
hello all, I have to parse a text file and get some value in that. text file content is as follows. ####TEXT FILE CONTENT STARTS HERE ##### /start first 0x1234 AC /end
6
by: Glenn Owens | last post by:
OK I'm on a steep learning curve with XML et.al. and need some advice. I'm writing a B2B front door for a new application. I have multiple data suppliers all sending various formats of flat...
5
by: Geoff Pennington | last post by:
My VB.Net app reads an Excel file, processes it one row at a time, and when processing is complete writes the row to a database. The typical file will have several thousand rows and may take a...
4
by: jesuraj | last post by:
Hi, how can i read input from a data file which contains binary or hex values. I have to use the exact binary data for further processing.only limited number of bits are taken form the file(64...
5
by: B. Williams | last post by:
I need some assistance with random access file processing. I have a function that I would like to change from sequential file processing to random access. Thanks in advance. void...
20
by: Johan | last post by:
How can I include one XML file into another XML file (on the client side, in Firefox)? I think XInclude is just what I need, but Firefox doesn't support it:...
6
by: ivan.perak | last post by:
Hello, im a beginner in VB.NET... The thing i would like to do is as it follows.... I have a text file (list of names, every name to the next line) which is about 350000 lines long. I would...
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.