473,499 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

c sourse code needed

10 New Member
Write a program to remove the duplicated words present in the text files. The input is a text file containing words with duplication. Each line has a single word. There should not be any shuffling in the words and original word should be maintained and duplicated word should be removed.

Eg:

The file contains following lines

Input

One
Two
Three
Two
Five
Four
One
Six
Ten

Output:

One
Two
Three
Five
Four
Six
Ten

any one can write a c program for this if so any me for this
Jan 31 '08 #1
9 1578
Laharl
849 Recognized Expert Contributor
We're not going to do your homework for you. If you've started and are having a specific problem, we can help you with that, but we are not going to spoonfeed you code.
Jan 31 '08 #2
raviufor
10 New Member
We're not going to do your homework for you. If you've started and are having a specific problem, we can help you with that, but we are not going to spoonfeed you code.



no dude i went a while in this i used fgets method to get thhe string value but i dont know how to go to secound line and how to compare it ........ help me out plz................
Feb 5 '08 #3
sicarie
4,677 Recognized Expert Moderator Specialist
no dude i went a while in this i used fgets method to get thhe string value but i dont know how to go to secound line and how to compare it ........ help me out plz................
Use a loop. Then you can repeatedly call whatever input method you wish, and test against the End Of File (EOF) condition.
Feb 5 '08 #4
raviufor
10 New Member
Use a loop. Then you can repeatedly call whatever input method you wish, and test against the End Of File (EOF) condition.


ya but i am not well in c ........ can u give me the code for that
Feb 5 '08 #5
raviufor
10 New Member
ya but i am not well in c ........ can u give me the code for that

#include <stdio.h>

int main()
{
FILE * pFile;
char mystring [100];

pFile = fopen ("myfile.txt" , "r");
if (pFile == NULL) perror ("Error opening file");
else {
fgets (mystring , 100 , pFile);
puts (mystring);
fclose (pFile);
}
return 0;
}









i used this program it get me only the first word how to get the secound line and how i should compare it any one help me out plz
Feb 5 '08 #6
sicarie
4,677 Recognized Expert Moderator Specialist
The experts on this site are more than happy to help you with your problems but they cannot do your assignment/program for you. Attempt the assignment/program yourself first and post questions regarding any difficulties you have or about a particular function of the code that you don't know how to achieve (this means actually Google search "loops" and "EOF").

Please read the Posting Guidelines and particularly the Coursework Posting Guidelines.

Then when you are ready post a new question in this thread.

MODERATOR
Feb 5 '08 #7
raviufor
10 New Member
Yep, I know what EOF and loop is.... My doubt was the string that i got in fgets method now contains the string "one." Now my doubt was how i will take the 2nd string too if I know that I can put that in the while loop and inside the while loop I will put an if statement, and I will compare the two strings. Got it.

Now my question was how i should take second string from the text file.
Feb 5 '08 #8
sicarie
4,677 Recognized Expert Moderator Specialist
Yep, I know what EOF and loop is.... My doubt was the string that i got in fgets method now contains the string "one." Now my doubt was how i will take the 2nd string too if I know that I can put that in the while loop and inside the while loop I will put an if statement, and I will compare the two strings. Got it.

Now my question was how i should take second string from the text file.
The same way you took the first string?

Maybe use a different variable?
Feb 5 '08 #9
raviufor
10 New Member
The same way you took the first string?

Maybe use a different variable?

if i do by same way with bifferent variabe again it takes the same value one bcz the pointer all ways points to 0.........if i know how to get the data line by line i can code it ...........i am struck here only is there any other way i can proced it or is that my way of thinking is wrong help me out in this plz ....... i useed fseek method to go from position to position but the size of the string are not constact so i droped that idea also help me out in this really dam struck in this
Feb 5 '08 #10

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

Similar topics

67
4190
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. ...
35
1254
by: Geronimo W. Christ Esq | last post by:
Are there any scripts or tools out there that could look recursively through a group of C/C++ source files, and allow unreferenced function calls or values to be easily identified ? LXR is handy...
18
18295
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
65
12504
by: Skybuck Flying | last post by:
Hi, I needed a method to determine if a point was on a line segment in 2D. So I googled for some help and so far I have evaluated two methods. The first method was only a formula, the second...
7
1732
by: Alan Silver | last post by:
Hello, I have installed the 2.0 framework, and am looking at converting some of my 1.1 pages to use partial classes. I don't (yet) have VS2005, so I'm doing this by hand, but am having problems....
1
1440
by: Skumar | last post by:
hi to all i'm skumar i'm woking in VB.NET frame work i need to place a link to remote ftp page
10
2275
by: Noozer | last post by:
I'm writing an ASP application and have a noob question... I have a class that access an MS SQL database. I have another class also accesses an MS SQL database and this second class uses objects...
52
3153
by: Julie | last post by:
I'm supporting an application at work. Below are some code segments that I can't understand how they work. First let me say, I would never code this standard. I'm just really creeped out that it...
0
1447
by: ultradiv | last post by:
I have a VB.NET application partly built that produces an xml output (just a file at present) I have a .NET webserver and SQLserver 2000 I need to be able to send the xml to the webserver/database...
11
1408
by: Sachin Garg | last post by:
I need to build two executables from my code, one having all the code (and thus application features) and other not having it all. How to best manage the code that shouldn't go in one of the...
0
7134
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
7014
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
7180
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
7229
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...
1
6905
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
7395
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
5485
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,...
1
4921
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...
1
667
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.