Thread: Weird Ouput

  1. #31
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    That helped. There was something I had forgotten that you have figured out... adding spaces (or some other character) to fill the line.

    So the problem is that on two of those lines (the two that are shorter than the maximum length) the first character in the line is missing, right? I don't see the problem straight away, but at least you've narrowed the problem to a specific issue.

    One question I have is for lines that are more than one character shorter than the maximum, doesn't your code only add a single space? I would think you should add a loop for adding the spaces to the end if it is shorter than the width.

  2. #32
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You will need to fill all locations up to "width-1" when you get to a '\n', not just replace the '\n' at 'x-1'. You are printing "random" garbage from the locations between those points.

    --
    Mats

  3. #33
    Registered User
    Join Date
    Aug 2007
    Posts
    25
    Oh! is that what the random garbage was that whole time? Because I hadn't specified what I wanted in that memory space yet?

    Edit: All fixed! It seems it was an issue with window line-endings (LF+CR) not being compatible with unix (just LF) so it was counting an extra character on every line.

    As far as I can tell it's all fixed. Thankyou SOOOOO much to everyone who helped. I know I'm a pain. Thanks.
    Last edited by addle_brains; 08-18-2007 at 05:09 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. weird things with my linked list of queue
    By -EquinoX- in forum C Programming
    Replies: 3
    Last Post: 11-22-2008, 11:23 PM
  2. weird
    By kiz in forum C Programming
    Replies: 8
    Last Post: 09-24-2007, 01:16 AM
  3. Weird Characters With GetDlgItemText
    By execute in forum Windows Programming
    Replies: 4
    Last Post: 05-04-2006, 04:53 PM
  4. weird error
    By gandalf_bar in forum Linux Programming
    Replies: 2
    Last Post: 07-17-2005, 07:32 AM
  5. Getting weird characters in Strings
    By steve8820 in forum C Programming
    Replies: 3
    Last Post: 09-18-2001, 02:49 AM