Thread: How can i search,edit, and replace new info by opening a text file in c++ program

  1. #1
    Registered User
    Join Date
    Jan 2019
    Posts
    1

    Exclamation How can i search,edit, and replace new info by opening a text file in c++ program

    i need some urgent help in completing this project of creating a program which can create and store info. I am half way through as i have programmed it till creating a file and adding useful information into it but now i am having difficulty in searching for data using a program made in c++ in a text file along with modifying the data searched. Can anyone help me?? i am not extremely good in programming , just a beginner> plz help!

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    You're going to need to post your code and ask specific questions based on the code provided.

    I am half way through as i have programmed it till creating a file and adding useful information into it but now i am having difficulty in searching for data using a program made in c++ in a text file along with modifying the data searched.
    Do you realize that you posted this in the C forum and that the two languages are not the same?

  3. #3
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    There are many ways to do this, from regular expressions to full-fledged xml parsers, but since you're a beginner you should stick with the basics. fgets() and sscanf(). Look them up, read on what they do and use them for your project.

    Oops, sorry, I instinctively answered having C in mind instead of C++. For C++ you'll need strings, getline and stringstreams. Or you could skip the buffering and read directly from the file.
    Last edited by GReaper; 01-01-2019 at 11:59 AM.
    Devoted my life to programming...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Search and edit structure in binary file
    By ghost00359 in forum C Programming
    Replies: 5
    Last Post: 05-28-2016, 07:59 AM
  2. Replies: 2
    Last Post: 02-03-2015, 10:19 AM
  3. Replace wildcard text in file with specific text.
    By untz in forum C++ Programming
    Replies: 4
    Last Post: 11-22-2010, 06:35 PM
  4. Search-result-opening program
    By Verdagon in forum C++ Programming
    Replies: 3
    Last Post: 08-02-2005, 05:41 PM
  5. performing a search-and-replace operation on a file
    By dakolmon in forum C++ Programming
    Replies: 2
    Last Post: 05-11-2004, 10:58 AM

Tags for this Thread