Thread: read file: from, if

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    3

    read file: from, if

    Hi!

    I have large log file with tables - heres a short example:

    33 1 1 1 1 1.000 0/0 0/0 0.000 1.000
    36 1 1 1 1 1.000 0/0 0/0 0.000 1.000
    39 1 1 2 2 0.500 0.000 0.000 0.500 0.750
    42 2 2 2 2 1.000 0/0 0/0 0.000 1.000
    43 2 2 2 2 1.000 0/0 0/0 0.000 1.000
    (numbers should be aligned)


    program should read first number (up to 5digits) in line if it satisfies a certain condition - 4digit number in the same line as number to test (0.500-TRUE, 0.000-FALSE)

    How can i put in this condition?

  2. #2
    Banned
    Join Date
    Jun 2005
    Posts
    594
    maybe a little more elaboration, but ill take a stab
    at it.

    if the number will always be where you expect them you can just
    ignore the number until you read the one you want,
    then a simple if statment, such as
    Code:
    if(number == 0.500) { // do this }
    where of course number is a double or float
    if your dont know for sure what number
    it will be but all you need to do is know
    if its larger then 0 you could do

    Code:
    if(number > 0) { // do this }
    if you could be a little clearer on what you need accomplished,
    possibly post code you already have i wills tick around
    till we get your problem solved.

  3. #3
    Registered User
    Join Date
    Jul 2005
    Posts
    3
    thanks, havent thought of that!

    i just started (2 weeks ago) to learn to program and i dont know exactly how to make this program - i havent made a code - yet. i have an idea what steps should it make, so i know what to look for - exept for that problem...

    thanks again

  4. #4
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    read file: from, if
    program should read first number (up to 5digits) in line if it satisfies a certain condition - 4digit number in the same line as number to test (0.500-TRUE, 0.000-FALSE)
    If you ever need a recommendation to apply for a job as a Navajo code talker, let me know.

  5. #5
    Registered User
    Join Date
    Jul 2005
    Posts
    3
    if I get Mel Gibson to protect me, yes please!

    ok, I`ll try again (to practice)...
    My program should: open a file; read numbers (N) from the begining of a line to first space; check for condition, which is in the same line columns 58-62; if condition True write N to another file (or on screan); procced to next line;

    hope thats better.

    Can you recommend me some book for a begginer ( is Pratas C++ Primer Plus Ok?)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  2. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  3. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  4. Hmm....help me take a look at this: File Encryptor
    By heljy in forum C Programming
    Replies: 3
    Last Post: 03-23-2002, 10:57 AM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM