Can any body tell me how to find duplicate lines in C
i have tried to find using Binary tree and Text files but not suceeded
..
It works for Word but not for lines
please help me
you can write suggetion to my email : rs******@gmail. com 5 2123
Put the lines in an array,
sort the array by a) length of line, b) the line itself
iterate the array checking for duplicates.
Regards, Stephan RS******@gmail. com wrote: Can any body tell me how to find duplicate lines in C
i have tried to find using Binary tree and Text files but not suceeded .
It works for Word but not for lines
please help me
Your question isn't really a "C" question, but more an algorithm one.
comp.programmin g might be a better place to ask it.
Assuming you can slurp the whole file into an array (i.e. assuming
you don't need to work on really big files, etc), you could use
the following simple approach.
1) slurp file into array (look at fgets, or cbfalconer's ggets code)
2) sort the array (look at quicksort)
3) iterate through the array, comparing each line to the next (look at
strcmp)
I expect is a good enough approach. Write some code and come
back with it if you have problems.
you can write suggetion to my email : rs******@gmail. com
No thanks, I prefer to post :p
-David
"Christophe r Benson-Manica" writes: RS******@gmail. com wrote:
i have tried to find using Binary tree and Text files but not suceeded
How sad. Are you sure you didn't simply make a mistake in your code?
I doubt that there are any real problems in doing this using a tree; it may
not be the best way but it is surely *a* way. Or did you mean you just gave
up and stopped working on it? BTW, the proper forum for this question is
comp.programmin g. RS******@gmail. com writes: Can any body tell me how to find duplicate lines in C
i have tried to find using Binary tree and Text files but not suceeded .
It works for Word but not for lines
The first thing you should do is figure out *why* it works for words
but not for lines. The code that checks for duplicates should just be
operating on strings; it shouldn't matter whether the strings are
words or lines.
Show us some code, and maybe we can help you figure out what the
problem is.
(If you're having problems with the algorithm, try comp.programmin g;
if you've having problems implementing the algorithm in C, you're in
the right place.)
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: mike |
last post by:
I have created a side application in VB.NET which reads
rows from a DB and builds an email message.
when i have a long string the the mailmessage.body or the
mailmessage, it puts in an "!<linefeed><space>" at about
every 980th space. I have confirmed that these characters
are not in the string or the message body before the email
is sent. Has anyone seen this or have any thoughts?
Thanks
|
by: George B |
last post by:
When I redirect standard output, I would like to duplicate a few lines of
this output to the console. If I add duplicates of the desired source
statements, changing cout to cerr, it works fine, but I end up with
duplicated lines when the program is executed without redirection. Is there
a way to test cout to tell whether its output is being redirected?
Like,
cout << "This information is very important" << endl;
if (cout_is_redirected)...
|
by: Pablo |
last post by:
Hello, there,
I have a table tblData which has pharmacy data. The table has
following fields:
ClaimNum, LineNum...
The ClaimNum has claim number which is 12 characters. LineNum is NULL.
The table looks like this
ClaimNum LineNum
abcde1234561
abcde1234561
|
by: Morgan Cheng |
last post by:
Hi All,
I was taught that argument valuse is not supposed to be changed in
function body. Say, below code is not good.
void foo1(int x)
{
x ++;
printf("x+1 = %d\n", x);
}
It should be "refactor-ed" to be
|
by: Sharon |
last post by:
Usually it is common to write the class member function in the class H file,
but some people like to write the function body in the C++ file.
Can anybody tell me what are the cases where inline function should not be
written in the C++ file? Or what are the disadvantages of inline function
body in a C++ file?
--
Regards
Sharon G.
| |
by: Kevin Blount |
last post by:
I've been trying all morning to find a way that will let me add new
lines to a string that will form the body of an email. The problem is
that some lines are not appearing as new line, but rather are being
appended to existing lines. Here's my (cut down) code:
string sbInstructions = string.Empty;
char endOfLine = '\n';
sbInstructions += "" + endOfLine;
sbInstructions += "DupCheck=email" + endOfLine;
|
by: JRWarring |
last post by:
I have a VB application with about 75 installations that uses the Crystal Control (Version 7.0) to print Crystal RPTs. On about 7 of these installations the clients are getting duplicate lines (usually on the last page or a single page report).
1) Using the same data (and reports) we cannot create this problem on any workstations execpt the 7 workstations that have the problem.
2) We do not think it a data problem, since we can clearly see in...
|
by: sadieslc |
last post by:
I'm working on a PHP script, and the info from the form shows up in the headers of the email that I receive, but it doesn't show up in the body of the email. Can you please help me figure out what I'm doing wrong?
Here is the script:
<? function send_mail($emailaddress, $fromaddress, $emailsubject, $body)
{
$eol="\r\n";
$mime_boundary=md5(time());
# Common Headers
|
by: VinArt |
last post by:
MS Acc 2003, XP
Thank you in advance for any help.
I have tables called "Makeup" and "Lines". Each makeup can have multiple lines.
Goal is to create a new "makeup" with identical "lines" except with a new makeup id.
I created a form Makeup Copy with Line Subform. In the main form there is ID (key field), Comments, Customer, Description plus an unbound field "NewMakeup". Each line of the subform has the fields "Makeup (primary...
|
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...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |