Thread: Outputting to end of line

  1. #1
    Registered User
    Join Date
    Feb 2003

    Outputting to end of line

    Ok this is MFC if it makes a difference....We have to make a text reader so to speak, and she wants it to have no horizontal scrolls...She wants us to make it so that if a word is going to be split at the end of the window, to not print that word, and bring it down to the next line....I have a few ideas on how to do this but is there someone out there with a given way?

    my idea: I'll just print out 1 word at a time, and then just use the getwidth (forget the actual function), if each letter, and have that loop until the end of the word....after each iteration, ill increment the count of pixels needed, then after the word is complete, simply check if its smaller then the room left, and if it is, print it out...if its not, is where i get lost....this is using files, so how exactly would i go back to the beginning of the word?

  2. #2
    Registered User
    Join Date
    Feb 2003
    You need to create an extra variable that contains the length (in letters) of the word as you're reading it. Thus, if you need to you can set the file the file pointer back to the beginning of the word, like this:

    int WordLength;
    // ...
     // ...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. Could somebody please help me with this C program
    By brett73 in forum C Programming
    Replies: 6
    Last Post: 11-25-2004, 02:19 AM
  3. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM
  4. end of line.
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2002, 05:01 AM