473,770 Members | 1,989 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unix C programming for finding file

Hi all,
I am now working on a C program under Unix.
The requirement for the program is that:
A file name is passed to program as a parameter. The program will
Find files under a specified directory. The matched file must have the
same content with the given file. It does not matter whether the
filenames are the same.

It is easy to find file that has the same name with given file, but
may be hard to find the files that with the same content. In my
knowledge, i give two solutions:

1) Go throught the directory and its sub direcotry tree, and when
meeting a file, Use the stand C library function to open that file and
the given file, and then compare those contents in buffers to see if
they are the same.

2) Go through the directory and its sub deirectroy tree, and when
meeting a file, execute the system shell command "diff" to compare the
two files to see if they are the same in content.
The two solutions seems not very smart and they are very running
slowly. I wonder if there is any library function that can compare two
file contents just like "strcmp" to compare two string.
Or maybe there are some other smart ways to achieve it.

Thank you for suggestions.
Nov 14 '05
46 2538

"Dan Pop" <Da*****@cern.c h> wrote in message
news:co******** **@sunnews.cern .ch...
In <co***********@ pc-news.cogsci.ed. ac.uk> ri*****@cogsci. ed.ac.uk (Richard Tobin) writes:

<snip>
Without such authorities there is no proper definition of the English
language, which basically means that anyone is free to bastardise it in
any way he sees fit without being technically wrong.


Which is pretty much how the English language (and any other) came to be.
Long before there were any officials to call it technically wrong.
Nov 14 '05 #41
Ok, last try, then I give up.

In article <co**********@s unnews.cern.ch> , Dan Pop <Da*****@cern.c h> wrote:
If BSI adopted the respective ISO standard, it is "official" without
qualificatio n.
Official for those things that the BSI standard applies to. Not
everything is standardised.
You're invoking a read herring: I've made NO claims about the English
language at large, have I?
See below.
There are plenty of native English speakers using the incorrect spellings.
How about *their* usage? How can you convince them that they are wrong,
as long as they are as native English speakers as yourself?
Perhaps I could persuade them that they had misremembered it, by
showing them numerous examples of the usual spelling. Or perhaps
I wouldn't be able to convince them.
That, if one native English speaker uses the incorrect form of an
irregular verb, you have no basis to correct him: his usage is as good as
yours, in the absence of a higher regulatory authority.
You might as well say that there is no basis to say that someone with
measles is ill, in the absence of a higher authority to define
wellness. What is English can be determined by observation of English
speakers. (Not, of course, by observation of any one English
speaker.)
Well, perhaps you better define it. If you restricted it to "country
names in ISO conformant systems" then obviously you would be right.
But you referred to "the official English spellings" which is a rather
wider claim.


On the contrary, I've made an extremely specific claim:

"Romania" is the current official English spelling.


The widening I referred to was from "English in ISO conformant
systems" to "English", not from one word to the whole language.
Without such authorities there is no proper definition of the English
language
Bingo! There is indeed no proper definition of English, just what we
observe, and this is only a problem worth solving for certain specific
areas, such as interoperabilit y of coputer programs.
which basically means that anyone is free to bastardise it in
any way he sees fit without being technically wrong.


Good heavens. How could we possibly stand for that?

-- Richard
Nov 14 '05 #42

In article <co***********@ pc-news.cogsci.ed. ac.uk>, ri*****@cogsci. ed.ac.uk (Richard Tobin) writes:
In article <co**********@s unnews.cern.ch> , Dan Pop <Da*****@cern.c h> wrote:
Then, on what basis are considered spellings like "recieve", "seperate"
or "tomarrow" incorrect?
Usage. Correct English is determined by the usage of English
speakers.


Or more precisely, by the dominant usage in the language-use context.
Usage varies, of course. Some forms predominate, due to various
factors such as popularity, use by the politically powerful classes,
presence in various media, and so forth. But they predominate only
in specific contexts; in others, regional or other variations may be
more influential in determining what a given speaker or author and
audience will consider "correct".

Of course, many usages get codified, and many users like to point to
such codices as authorities, but they're no more authoritative than
users grant. They have no special status.
As a native English speaker, I admit no other authority on the matter.


A reasonable position, and the right one in my view, though of course
any English speaker can choose to defer to some language "authority" .
What they can't do is demonstrate that it applies, or should apply,
to all English speakers.
Who's maintaining the list of irregular verbs
and who's giving that organisation the authority to do so?


No-one of course.


Well, there are certainly people who maintain such lists, such as
the authors of English grammar and usage primers. Whatever authority
they have comes solely from the decisions made to publish and purchase
those books.

That said, I imagine I'd consider ISO 3166 a standard for English
spelling of country names, though I'd want to read it first before I
committed to that position. And clearly it is "official" in a useful
sense. However, I wouldn't call it an "official English standard";
I'd call it an "official standard for spellings (of country names) in
English". That may seem like a fine distinction, but I think it's
significant, as it implies that its office pertains to certain
spellings rather than to English per se.

--
Michael Wojcik mi************@ microfocus.com

I would never understand our engineer. But is there anything in this world
that *isn't* made out of words? -- Tawada Yoko (trans. Margaret Mitsutani)
Nov 14 '05 #43
In <41************ ***********@dre ader13.news.xs4 all.nl> "dandelion" <da*******@mead ow.net> writes:

"Dan Pop" <Da*****@cern.c h> wrote in message
news:co******* ***@sunnews.cer n.ch...
In <co***********@ pc-news.cogsci.ed. ac.uk> ri*****@cogsci. ed.ac.uk

(Richard Tobin) writes:

<snip>
Without such authorities there is no proper definition of the English
language, which basically means that anyone is free to bastardise it in
any way he sees fit without being technically wrong.


Which is pretty much how the English language (and any other) came to be.
Long before there were any officials to call it technically wrong.


This is also true for everything that eventually got standardised.
Anything wrong with having standards?

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Currently looking for a job in the European Union
Nov 14 '05 #44
In <co**********@p c-news.cogsci.ed. ac.uk> ri*****@cogsci. ed.ac.uk (Richard Tobin) writes:
Ok, last try, then I give up.

In article <co**********@s unnews.cern.ch> , Dan Pop <Da*****@cern.c h> wrote:
If BSI adopted the respective ISO standard, it is "official" without
qualification .
Official for those things that the BSI standard applies to. Not
everything is standardised.


Country names are standardised, so the official English spelling is
"Romania", which is the starting point of this discussion.
There are plenty of native English speakers using the incorrect spellings.
How about *their* usage? How can you convince them that they are wrong,
as long as they are as native English speakers as yourself?


Perhaps I could persuade them that they had misremembered it, by
showing them numerous examples of the usual spelling. Or perhaps
I wouldn't be able to convince them.


That's why a language authority is a good thing. Languages having such
an authority don't have three different spellings for "Romania" :-)
That, if one native English speaker uses the incorrect form of an
irregular verb, you have no basis to correct him: his usage is as good as
yours, in the absence of a higher regulatory authority.


You might as well say that there is no basis to say that someone with
measles is ill, in the absence of a higher authority to define
wellness.


As long as there is a higher authority to define measles as an illness,
you don't need anything more.
What is English can be determined by observation of English
speakers. (Not, of course, by observation of any one English
speaker.)
The result of such an observation is a complete mess. If you don't
believe me, go and rent a copy of "My Fair Lady" :-)

Non-authoritative as they are, dictionaries are still the only reliable
source of information about what is English. Which is why it is downright
stupid not to have an authoritative dictionary of the English language.
Well, perhaps you better define it. If you restricted it to "country
names in ISO conformant systems" then obviously you would be right.
But you referred to "the official English spellings" which is a rather
wider claim.


On the contrary, I've made an extremely specific claim:

"Romania" is the current official English spelling.


The widening I referred to was from "English in ISO conformant
systems" to "English", not from one word to the whole language.


"English in ISO conformant systems" doesn't make much sense to me.
You have English in an official context and colloquial English.
In the former, there is only one spelling for Romania, in the latter there
are three. Feel free to prove me wrong.
Without such authorities there is no proper definition of the English
language


Bingo! There is indeed no proper definition of English, just what we
observe,


Then why do people buy and use dictionaries? Why do they bother inquiring
about the spelling of one word or another?
and this is only a problem worth solving for certain specific
areas, such as interoperabilit y of coputer programs.


It is a problem anywhere precise communication is important.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Currently looking for a job in the European Union
Nov 14 '05 #45

In article <co**********@s unnews.cern.ch> , Da*****@cern.ch (Dan Pop) writes:

Without such authorities there is no proper definition of the English
language, which basically means that anyone is free to bastardise it in
any way he sees fit without being technically wrong.


And indeed that is precisely the situation, and has been for the
entire time the English language has existed. So what?

--
Michael Wojcik mi************@ microfocus.com
Nov 14 '05 #46
In <cp*********@ne ws3.newsguy.com > mw*****@newsguy .com (Michael Wojcik) writes:

In article <co**********@s unnews.cern.ch> , Da*****@cern.ch (Dan Pop) writes:

Without such authorities there is no proper definition of the English
language, which basically means that anyone is free to bastardise it in
any way he sees fit without being technically wrong.


And indeed that is precisely the situation, and has been for the
entire time the English language has existed. So what?


So the poor usage of (especially written) English among its native
speakers. If their usage is as good as anyone else's, in the absence of
any authoritative reference, why should they bother to improve it?

So the confusion among the people trying to learn English as a foreign
language and being exposed to multiple spellings of the same word, some
accepted by the dictionaries, some not, but none of them incorrect in the
absence of an authoritative reference.

So the proliferation of multiple spellings for the same word, which
is hardly a good thing. So the creation of unneeded words, like
"irregardle ss".

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Currently looking for a job in the European Union
Nov 14 '05 #47

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

Similar topics

270
3990
by: Jatinder | last post by:
I found these questions on a web site and wish to share with all of u out there,Can SomeOne Solve these Porgramming puzzles. Programming Puzzles Some companies certainly ask for these things. Specially Microsoft. Here are my favorite puzzles. Don't send me emails asking for the solutions.
5
2729
by: jrefactors | last post by:
when people say unix programmer, does it mean they write programs in unix environment,and those programs are run in unix platform? it is not necessary they are using unix function calls? I heard most of the time unix programmers are C and C++ programmers. please advise. thanks!!
48
2604
by: Daniel Rudy | last post by:
Hello, On a x86 machine, what is the format of a pointer in C? I know for a fact that the x86 p-mode uses a /selector:offset/ notation where the selector is defined in either the GDT or LDT. Does that carry over into the pointer, or does Unix use the flat memory model? -- Daniel Rudy
6
16392
by: Joseph | last post by:
Hi, I am trying to develop a C# application that will run on Windows that will do the following * Select file name to process * FTP the file to a UNIX server * Process this file on UNIX using a program on UNIX "./pgmname -options Infilename > OutputFilename" * FTP the output of this program back to Windows * Process the resultant file and create output report file
4
2371
by: Michael | last post by:
Hi, I'm having difficulty finding any previous discussion on this -- I keep finding people either having problems calling os.exec(lepev), or with using python's exec statement. Neither of which I mean here. Just for a moment, let's just take one definition for one of the
7
2069
by: programming | last post by:
Hi all, i have been having trouble with a login script that works on my windows machine, however when i upload it to the Unix server through VPN, the same script won't work! It won't parse member.txt properly i think. The password and usernames i am using are at the bottom of this post. Each time i go to login on the unix server, it clears the username and password field. I have been attempting to solve the problem, but have been...
2
1596
by: frikk | last post by:
Hey everyone, (Sorry about the first message if it made it - i got cut off early). I have a homework problem for my Operating Systems class. I am supposed to use a command such as "ps -aux" and return "N number of users, M number of processes". How am I to go about doing this? I am not very familiar with string parsing in c++, is this the only way? I am talking about getting the output from "ps -aux" and parsing it to retrieve the...
21
3038
by: Tom Gur | last post by:
Hi, It's seems that csh and tcsh acts a bit different when handling special characters in quotes. i.e: if i'll supply my program with the following arguments: -winpath "c:\\temp\\" tcsh will take it as -winpath "c:\temp\" and csh will take it literally (with the double-slashes). Is there a way for me to know what shell is currently running my
65
5101
by: Hongyu | last post by:
Dear all: I am trying to write to a file with full directory name and file name specified (./outdir/mytestout.txt where . is the current directory) in C programming language and under Unix, but got errors of Failed to open file ./outdir/mytestout.txt. Below is the code: #include <stdio.h>
0
9618
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10259
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10101
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9906
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7456
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.