Thread: How to search and output the result from text file in c

  1. #1
    Registered User
    Join Date
    Aug 2015
    Posts
    1

    Question How to search and output the result from text file in c

    Good day everyone
    I'm a new member in this forum. I started learning c this summer.
    Question:
    I have a task: There are more than 100 English-Chinese words in a text file called ciku.txt like: China = 中国
    I have to write a program to read this text file and when user inputs China it should give me China = 中国
    Please, tell me how to start my program in steps. And how should I read a text file into an array and search from array?
    P.S.: Sorry for my English

  2. #2
    Registered User FourAngels's Avatar
    Join Date
    Aug 2015
    Location
    Canada
    Posts
    130
    In c you have to make a user defined record for the data contained in the file. The struct type will allow you to store the data in a type. It would be necessary to see the first few lines of the contents of the data file, and than you can write the function to read the data into the record.

    From there you can add more functionality. It looks like you would need to be able to search the records, so therefore you would need to get the user input and find the matching word in your records...than output matching the record.
    Last edited by FourAngels; 08-26-2015 at 11:07 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Search string in a text file
    By stud91 in forum C Programming
    Replies: 18
    Last Post: 09-25-2011, 04:14 PM
  2. Store Multiple result into a text file using fstream
    By yappy in forum C++ Programming
    Replies: 4
    Last Post: 07-30-2010, 08:33 PM
  3. word search in a text file
    By willie in forum C Programming
    Replies: 3
    Last Post: 11-20-2008, 11:10 AM
  4. search text from file
    By bradleyd in forum C++ Programming
    Replies: 11
    Last Post: 07-07-2008, 10:54 AM
  5. Search text in file
    By MarlonDean in forum C++ Programming
    Replies: 10
    Last Post: 05-16-2008, 03:51 AM

Tags for this Thread