Thread: How does I check for periods?

  1. #1
    Unregistered
    Guest

    How does I check for periods?

    I am writing a program using linked lists. A data file with multiple sentences are stringed together in one line. For example:

    I have a dog. I have a cat. I hate dogs and cats.

    I need to identify each sentence... and I believe the way to do this is to check for periods. What kind of function do I need to write to check for periods?

  2. #2
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Location
    Bangalore, India
    Posts
    345
    Sentences not always end with '.', but since you have presumed sentences to end with '.',

    Code:
    main()
    {
            char t_str[255], *str = "I have a dog. I have a cat. I hate dogs and cats.";
            int i;
    
            while(*str) {
                    i = 0;
                    while(*str && *str != '.') {
                            t_str[i ++] = *str ++;
                    }
                    t_str[i] = '\0';
                    puts(t_str);
    
                    *str ++;
            }
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BN_CLICKED, change button style
    By bennyandthejets in forum Windows Programming
    Replies: 13
    Last Post: 07-05-2010, 11:42 PM
  2. How can i check a directory for certain files?
    By patrioticpar883 in forum C++ Programming
    Replies: 13
    Last Post: 02-01-2008, 05:27 PM
  3. how to check input is decimal or not?
    By kalamram in forum C Programming
    Replies: 3
    Last Post: 08-31-2007, 07:07 PM
  4. Please check this loop
    By Daesom in forum C++ Programming
    Replies: 13
    Last Post: 11-02-2006, 01:52 AM
  5. how to check for end of line in a text file
    By anooj123 in forum C++ Programming
    Replies: 6
    Last Post: 10-24-2002, 11:21 PM