Thread: Current Project

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    60

    Current Project

    I have just started a project in which I need to convert an input such as

    Xy xY

    into a logic statement as below

    (((NOT x) AND y) OR (x AND (NOT y)))

    I have written a program to read in the input from the user which stores it in a single string field.

    I think the next step is to split up each of the characters in the string field so they can be converted to the logic statements. Is this correct? or is there an easier way.

    also is it possible to get a program to recognise capital letters, as these need to be NOT statements.

    I would just like to be pointed in the right direction so I can work out how to do this myself, I have tried looking through the tutorials but these don't seem to match what I need my program to do.

    Thanks for any help in advance
    Aaron

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    10
    As I understand your problem, you want to look nito a string. With any type of string, weather it is a declared or designed structure (or in C++ even a class) or simply just an array of characters [char *], you can look at individual elements.

    I am not entirely sure this is the best or most efficient way, but if you were to have an array of characters like the following:
    Code:
       char Expression[] = "Xy xY";
    you could simply run through the array and look for characters with a
    Code:
       int i;
       for(i = 0;Expression[i] != '\0';i++)
       {
           // do your checking
       }
    you can even make an array of variables, which get expanded every time you find a character you have not found before.

  3. #3
    Register User andor's Avatar
    Join Date
    Aug 2006
    Location
    Novi Sad
    Posts
    42
    Yes I think splitting the chars of the input is good idea. To recognise capitals you can use funcs as islower or isupper in ctype.h header. So if there is no space (' ') between chars than its OR, otherwise its AND.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Open-source Game Project
    By Glorfindel in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 03-24-2009, 01:12 AM
  2. Need help with program.
    By olgirl4life in forum C++ Programming
    Replies: 3
    Last Post: 12-11-2006, 11:06 PM
  3. BST delete again, but this time I think I'm close
    By tms43 in forum C++ Programming
    Replies: 9
    Last Post: 11-05-2006, 06:24 PM
  4. Problem with simple case statements
    By shoobsie in forum C Programming
    Replies: 2
    Last Post: 05-08-2006, 08:39 AM
  5. DJGPP project problems
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 06-08-2002, 07:16 PM