Thread: Switching letters

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    27

    Switching letters

    I need a program that switchs letters into other letters and i don't know how to make the letters switch please help.

  2. #2
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    Do you mean encrypting the text? If so, just define your key (the encryption/decryption code) then write a function that reads through a string character by character, runs the character against the key to change it then write it out to the encrypted string.

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    27
    no it's like a translator but in to a langauge i made.

  4. #4
    Registered User
    Join Date
    Mar 2002
    Posts
    27
    The idea is you type the Enlish in one box "IDC_EDIT_SECOND"

    and it come out in the other langauge in box "IDC_EDIT_SHOW"


    here is the code

    Code:
    void CReversDlg::OnChangeEditSecond() 
    {
    	// TODO: If this is a RICHEDIT control, the control will not
    	// send this notification unless you override the CDialog::OnInitDialog()
    	// function and call CRichEditCtrl().SetEventMask()
    	// with the ENM_CHANGE flag ORed into the mask.
    	
    	// TODO: Add your control notification handler code here
    	
    	
    	CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT_SECOND);
    	CEdit* pEditShow = (CEdit*)GetDlgItem(IDC_EDIT_SHOW);
    
    	CString strText;
    
    	pEdit->GetWindowText(strText);
    
    	//switch letter's in strText here
                    //
    	pEditShow->SetWindowText(strText);
    	
    }

  5. #5
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    Basically the same method I mentioned above will apply but with slight modifications. Define your a dictionary of your custom language with an array or linked list. When you need to translate the english to your language read their text (word by word) into a temp string. Use strcmp to find a match (or if you want to allow for spelling corrections - find the closest match). Once you find it write the match into a new string. For each word to be translated, concatenate the new translated word onto the former ones. When you've finished output the new translated string into the edit box.

    If you're looking for speed you will want to tinker with the string parser (the strcmp part) so that it first checks the first initial, then the 2nd, and so on. ie: if the word starts with a "d", then until a match is found only search entries in your dictionary that start with a "d", etc. etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Generating random letters
    By ominub in forum C Programming
    Replies: 6
    Last Post: 04-29-2009, 01:12 AM
  2. need to count individual letters in input
    By epox in forum C Programming
    Replies: 12
    Last Post: 05-22-2006, 06:32 AM
  3. Counting letters and digits
    By FeNCinGeR in forum C++ Programming
    Replies: 3
    Last Post: 04-06-2006, 11:39 AM
  4. Switching frequency and Bandwidth???
    By pastecopy in forum Tech Board
    Replies: 0
    Last Post: 03-23-2003, 11:13 AM
  5. Sorting inputed letters alphabetically...
    By IanelarAzure in forum C++ Programming
    Replies: 6
    Last Post: 09-30-2002, 08:56 PM