• Advertisement
Sign in to follow this  

i need the code of the program, plz help

This topic is 4221 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Write a C++ program that’ll perform the following: 1. Get character input from user (with spaces) 2. Search that input in a text file (search should be case sensitive) 3. Search should be done line by line. 4. If found then change it to upper case and write it back at the end of the file. 5. Display the line number and character no where you have found the string.

Share this post


Link to post
Share on other sites
Advertisement
Okay, this really sounds like homework, so I can give you some hints, but if it is homework, no one here will give you the code for it.

1. I reccommend you look into the function 'fgets'
2/3. Not hard - read in a file line by line and just search each line character by character - you'll need a loop.
4. Not hard.
5. Not hard - keep track of how many lines you've read, and how many characters into the string you found the input.

Share this post


Link to post
Share on other sites
Quote:
Original post by Endar
1. I reccommend you look into the function 'fgets'

Actually, I strongly recommend against using fgets()/char *. You would be better off with std::getline() and std::string.

Share this post


Link to post
Share on other sites
fgets is not the correct way to do things in C++. Try ifstream instead.

To the OP: asking homework questions here is against forum policy. It's also not useful for you to ask others to do your work for you. The only way you'll learn to program properly is to practice yourself and learn how to solve these kinds of problems on your own. At the very least, as a show of good faith to people here who are willing to give up their time to help you, put in some effort first and post your questions if you get stuck - but don't ask people to do everything for you for free.

Share this post


Link to post
Share on other sites
Quote:
Original post by jflanglois
Quote:
Original post by Endar
1. I reccommend you look into the function 'fgets'

Actually, I strongly recommend against using fgets()/char *. You would be better off with std::getline() and std::string.


Actually yeah, what he said. [smile]

Share this post


Link to post
Share on other sites
Dears this is not the homework , i read this question in a book and i am unableto solve it , i want to understand how can this program be handled , please write the whole code of the program , i shall be very thankfull to you all.

Share this post


Link to post
Share on other sites
Quote:
Original post by MubasharIqbal
Dears this is not the homework , i read this question in a book and i am unableto solve it , i want to understand how can this program be handled , please write the whole code of the program , i shall be very thankfull to you all.


Well, if it is from a book, I assume you are attempting to learn. Us writing a full program for you will not help you at all. You will glance at the code, and not really learn. We definately want to give tips and such, but I doubt most of us would waste 20 minutes banging out the code.

Share this post


Link to post
Share on other sites
Quote:
Original post by MubasharIqbal
Dears this is not the homework , i read this question in a book and i am unableto solve it , i want to understand how can this program be handled , please write the whole code of the program , i shall be very thankfull to you all.


We can explain things that you don't understand, but it would be a very bad idea to give you the whole source code of this program.

Think to it again: your book want to teach you something. If you don't understand it, maybe you should read again the relevant parts of your book. But if we give you the complete source code, what will you understand? You will say "ah ok, it is done like this" but if you have to do it again you won't be able to remember what you learnt correctly because you never wrote it.

Programming is something you acquire with experience. What makes you a better programmer is not what you read from others but what you did with your own hands.

Again, I suggest you to read again the relevant part of your book, as I can't imagine that it doesn't give you all the clues to write the program correctly (I would find it weird if it tells you "write this" without giving any information on the subject before). Once you'll have done this, we'd be glad to help if you have further questions.

Regards,

Share this post


Link to post
Share on other sites
Quote:
Original post by MubasharIqbalDears this is not the homework , i read this question in a book and i am unableto solve it , i want to understand how can this program be handled , please write the whole code of the program , i shall be very thankfull to you all.


Which book?

Quote:

Write a C++ program that'll perform the following:
1. Get character input from user (with spaces)
2. Search that input in a text file (search should be case sensitive)
3. Search should be done line by line.
4. If found then change it to upper case and write it back at the end of the file.
5. Display the line number and character no where you have found the string.


Can some ody help to solve the assignment


(From here - emphasis mine)

Share this post


Link to post
Share on other sites
Quote:
Original post by MubasharIqbal
please write the whole code of the program


No. You need to show at least an effort in solving the problem. If you cannot so much as start to brainstorm on the subject, then this is a sign of one of the following:

1) You've failed to read the section of the book preceeding the question, and would be better off reading it as it explains what you need to know to proceed.
2) Your book is so shitty that it's not worth reading, and would be better off being replaced.
3) Your comprehension skills are in need of improvement, and would be better off being practiced.

All signs point to just handing you source code not being the best solution to your problem. It would be easier if your one and only goal is to answer your homework, but that won't teach you anything - and we're not interested in doing the work that others are too lazy to do for their own benifit.

Share this post


Link to post
Share on other sites
Even if this isn't homework, it unfortunately violates several parts of the Forum FAQ -- namely,

Quote:
In any case, we'd just like you to demonstrate that you've thought about the problem a little.


Asking us to do the busywork is not demonstrating that you've thought about the problem.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement