Searching For a Word in a file and outputing a number

This is a discussion on Searching For a Word in a file and outputing a number within the C Programming forums, part of the General Programming Boards category; Hello, I need help in C. I'm trying to automatically search a file for a word given the date, the ...

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    8

    Searching For a Word in a file and outputing a number

    Hello,

    I need help in C.

    I'm trying to automatically search a file for a word given the date, the file was created. After searching and finding that word. There should be a number in minutes next to the word. I want to scan that number and output it.

    Can someone help me with the code.


    For example:
    File name is "2001.05.12.txt"
    Word I'm searching for is "Hello"
    Next to that word should be some number "8"

  2. #2
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Well, you can just use some time functions to get the date and then when you open the file with the appended date in it. Then, when you read in the file, you get the string. Now, will it always be "Hello"? Otherwise, you can sort through all the chars in the file and tell if they are numerical or not.

    --Garfield
    1978 Silver Anniversary Corvette

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    8
    Thanks for the help,

    Program is working fine now.

    BC

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 13
    Last Post: 04-05-2009, 11:16 AM
  2. Help in outputing different file names in a loop
    By nightfallz in forum C++ Programming
    Replies: 3
    Last Post: 02-16-2009, 10:53 AM
  3. Outputing to a file
    By warfang in forum C++ Programming
    Replies: 17
    Last Post: 04-24-2007, 02:36 AM
  4. Outputing Results to a File
    By SITHDUKE in forum C++ Programming
    Replies: 11
    Last Post: 03-03-2005, 07:33 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21