Thread: Autocorrecting typing errors

  1. #1
    Registered User
    Join Date
    Nov 2017
    Posts
    9

    Autocorrecting typing errors

    I've been given an assignment question and im stuck. The question is:

    Write a program that reads an input text file, identifying and auto-correcting the following common typing errors: ‘Space before comma or a full-stop’, ‘Multiple spaces as opposed to a single space’, and ‘Missing spaces’.


    I can only go as far as making a text file in C and reading it but im oblivious about how the code should be in order to auto-correct the typing errors in the text file. Can someone please explain to me what needs to be done? Thanks

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    A first step might be add some code to scan through the text and output
    "Found a comma"
    "Found a fullstop"
    at the appropriate places.

    Then you can look at things like whether the preceding character as a space (or not).

    The essence of any programming is to break the problem down into achievable steps.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Nov 2017
    Posts
    9
    Im aware to the point that the fscanf fucntion will be used in the program but how it will autocorrect, i dont know. At first I thought I might have to write the program such that it will seek for the errors one by one and fixes them but that's not the case. How will I instruct the computer to autocorrect? is there some kind of function im not aware of?

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Read in a line using fgets()

    Use a for loop to examine each character in turn.

    If it's a letter, you print it.
    If it's a space, you save it (what happens depends on what you read next).

    Work through the logic and pick a couple of cases to implement.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Blood Typing
    By mszegedy in forum C Programming
    Replies: 4
    Last Post: 03-22-2011, 09:40 PM
  2. Is my typing correct
    By Aladdin in forum C Programming
    Replies: 2
    Last Post: 11-01-2010, 10:48 AM
  3. Touch typing
    By jacek in forum Tech Board
    Replies: 34
    Last Post: 12-01-2009, 10:27 PM
  4. typing with no output
    By rkjd2 in forum C++ Programming
    Replies: 1
    Last Post: 03-16-2002, 04:12 PM
  5. check for typing???
    By Goof Program in forum C Programming
    Replies: 8
    Last Post: 03-04-2002, 11:11 AM

Tags for this Thread