Thread: Simple spell checker

  1. #31
    Registered User
    Join Date
    Mar 2008
    Posts
    14
    Quote Originally Posted by matsp View Post
    Strange. Are you by any chance using a word-list generated by a Windows / DOS program on a Linux/Unix machine? That would explain the newline/carriage return problem.

    If so, you should use "dos2unix wordlist" to make sure the newlines are converted from CR+LF to LF only.

    --
    Mats
    Well, on my first attempt I was using Netbeans to create an empty text file which i added 10 words in for testing, and then on the second attempt I used the word list generated on unix.. Same results for both..

  2. #32
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Sorry, but I don't quite follow. Are you on a linux/unix system? If so, you could use "od -x wordlist" to list it in hex format. If you have ANY "0d" characters in the file, then you have a file with DOS/Windows style newlines, which is not what linux/unix expects, so you will need to strip them.

    Modifying your strip functionality like this would do:
    Code:
    for (i=0; i<sizeof(words)/sizeof(words[0]); i++) {
        char *p = strchr(words[i],'\n');
        char *q = strchr(words[i],'\r');
        if (q && q < p) p = q;
        if(p) {
            *p = '\0';
        }
    }

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  2. what SHOULD be a painfully simple API call...
    By Citizen Bleys in forum Windows Programming
    Replies: 3
    Last Post: 09-17-2003, 03:20 PM
  3. Simple simple graphics
    By triplem in forum C Programming
    Replies: 2
    Last Post: 05-19-2003, 02:52 AM
  4. spell checker in c needs help
    By madmax in forum C Programming
    Replies: 3
    Last Post: 03-13-2003, 09:36 AM
  5. spell checker
    By bob20 in forum Windows Programming
    Replies: 3
    Last Post: 12-03-2002, 02:35 AM