Thread: diff function

  1. #1
    Registered User
    Join Date
    Jan 2012
    Posts
    14

    diff function

    Hey, so I'm trying to write a program and am supposed to compare its output to the output I'm supposed to be getting using the diff function.

    What appears to be EXACTLY the same output is apparently not at all the same using the diff function. This is becoming extremely irritating to figure out. Any help would be greatly appreciated.

    Code:
    -------------- Report -----------------
    House price: $100000.00
    Amount borrowed: $100000.00
    Interest rate: 1.00;   Term: 30 years
    
    
    Monthly payment: $321.64
    Annual payment:  $3859.67
    Total amount to repay:   $115790.23
    Total interest payments: $15790.23
    Interest is 15.79% of the principal
    
    
    Down payment: $0.00 is 0.00% of house price
    Total spent on house: $115790.23
    
    
    --------------------------------------
    
    
    
    
    Full price: Incorrect value
    Principal: Incorrect value
    Interest: Incorrect value
    Term: Incorrect value
    Term: Incorrect value
    Full price: Incorrect value
    Principal greater than full price
    Principal greater than full price
    Term: Incorrect value
    and

    Code:
    -------------- Report -----------------
    House price: $100000.00
    Amount borrowed: $100000.00
    Interest rate: 1.00;   Term: 30 years
    
    
    Monthly payment: $321.64
    Annual payment:  $3859.67
    Total amount to repay:   $115790.23
    Total interest payments: $15790.23
    Interest is 15.79% of the principal
    
    
    Down payment: $0.00 is 0.00% of house price
    Total spent on the house: $115790.23
    
    
    --------------------------------------
    
    
    
    
    Full price: Incorrect value
    Principal: Incorrect value
    Interest: Incorrect value
    Term: Incorrect value
    Term: Incorrect value
    Full price: Incorrect value
    Principal greater than full price
    Principal greater than full price
    Term: Incorrect value

  2. #2
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    What does it say if you ignore whitespace with the -w option?

    EDIT: These two lines are different:
    Total spent on house: $115790.23
    Total spent on the house: $115790.23

    Didn't diff tell you that?
    Last edited by oogabooga; 01-28-2012 at 04:16 PM.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  3. #3
    Registered User
    Join Date
    Jan 2012
    Posts
    14
    No actually diff hasn't done squat for me it just outputs

    1,27c1,27

    and spits out both outputs again...

    thanks for noticing that difference though, it still does the same thing.

    apparently all the lines are different from eachother?

    ultimately though it needs to run without the -w and give me no output.

  4. #4
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    What does it do with -w?

    Could it be a difference in line endings? Are you creating it on a windows machine and diff'ing it on unix?
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  5. #5
    Registered User
    Join Date
    Jan 2012
    Posts
    14
    Was creating it on a windows ssh'd into a linux server to use diff.

    Just ran it with -w and got no output. So I'm assuming its some kind of line/spacing problem? I guess I gotta keep looking.

  6. #6
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    I tried to copy paste your text and ran diff on it, and the output was:

    Code:
    15c15
    < Total spent on house: $115790.23
    ---
    > Total spent on the house: $115790.23

  7. #7
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    Quote Originally Posted by greeziakattack View Post
    Was creating it on a windows ssh'd into a linux server to use diff. Just ran it with -w and got no output. So I'm assuming its some kind of line/spacing problem?
    Just ssh into the linux server, copy your source code over and compile and run it there. If for some reason you don't want to do that, you could maybe write to the file on windows in binary mode.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  8. #8
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Perhaps it's those pesky dos line breaks. You could try:

    Code:
    od -ba filename
    On both files.
    Last edited by Subsonics; 01-29-2012 at 01:59 PM. Reason: -ba makes more sense I guess.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. function that takes diff data types as paramter
    By nepdude in forum C Programming
    Replies: 7
    Last Post: 07-06-2007, 01:47 PM
  2. why does this code do something diff on 2 diff boxes?
    By crypto_quixote in forum C Programming
    Replies: 3
    Last Post: 03-08-2005, 12:11 PM
  3. What is the diff between if and #if?
    By correlcj in forum C Programming
    Replies: 5
    Last Post: 08-14-2002, 04:53 AM
  4. Diff compiler == diff program????
    By Imperito in forum C++ Programming
    Replies: 21
    Last Post: 04-25-2002, 12:50 PM
  5. ++i vs i++; what's the diff??
    By sballew in forum C Programming
    Replies: 4
    Last Post: 09-02-2001, 08:30 PM