473,725 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

issues with input (removing punctuation) from dictionary program

77 New Member
my program takes users input (words/sentance) and translates it from english to hmong. I have to main variables, but cannot post my entire code.

char In[999];
CString in;

basically the user cin >> In; then later in = In, then computes using the dictionary. is there anyway i can remove ! commas and periods from the input before translating in my dictionary? i keep getting error codes.

if i do this (first idea)

if (strcmp(In, "!") == 0) {
in = "love";} // In[i - 1];}

if you type in !, you get the word love translated (i used love as a test)

if you type in hello! (you get hello = ) then its blank since it doesn't seperate the word from the !... is there any way to compare the last letter of this special type of character since you cannot analyze it like an array. normally i would do In[j] = "!" or something, but its not a normal character/array so it wont let you look at a position and compare the input.

any ideas?

is there a simpler way in removing punctuation from the translation?

simple way to help me: how can i check/compare the last part of the word for lets say an !, and if it is found, replace it with a space?
Jul 26 '07
13 3044
jerger
77 New Member
in = In;

//in.ReleaseBuffe r(); // Things are now OK
punc = in.GetLength(); // This is guaranteed to be correct
while (in[punc] = '!'){
//in.TrimRight();
in = "love";
}



"..\..\..\..\.. \..\..\Translat or.cpp(127) : error C2106: '=' : left operand must be l-value"
Jul 27 '07 #11
jerger
77 New Member
i think i have to do something like this with the cstring, but not sure what to do yet to make it not crash

len = strlen(word); //this line made it stop crashing but now has no effect


//original post
if (in[len-1] == '.' || in[len-1] == '?')
in[len-1];= '\0';

//only works if i use == instead of =''\0" , if i do that i get error like cant use l-value


..\..\..\..\..\ ..\..\Translato r.cpp(147) : error C2106: '=' : left operand must be l-value
Build log was saved at "file://c:\Documents and Setting

in is a cstring, In is char 999

in = In; //important

//
//if (in[strlen(szInput) )] == '!')
//in = "love";
len = strlen(in);
if (in[len-1] == '.')
in[len-1] = '\0';
Jul 31 '07 #12
jerger
77 New Member
woot 4am i figured it out!

len = strlen(in);
if (in[len-1] == '.')
in = in.TrimRight('. ');
Jul 31 '07 #13
jerger
77 New Member
punk is int, len is int, in is cstring

//punctuation removal
//while loop checks several times to catch all punctuation

while (punk < 10){
len = strlen(in);
if (in.Left(1) == '"')
in = in.TrimLeft('"' );

if (in[len-1] == '.')
in = in.TrimRight('. ');

if (in[len-1] == '"')
in = in.TrimRight('" ');

if (in[len-1] == '!')
in = in.TrimRight('! ');

if (in[len-1] == ',')
in = in.TrimRight(', ');

if (in[len-1] == '?')
in = in.TrimRight('? ');

if (in[len-1] == ':')
in = in.TrimRight(': ');

if (in[len-1] == ';')
in = in.TrimRight('; ');

punk++;
}
punk = 0;
//end of punctuation check
Jul 31 '07 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

6
16987
by: JohnK | last post by:
ok, ya got me here. I'm trying to removing items from a dictionary inside a loop. Obviously using enumeration does not work as that assumes the dictionary stays unchanged. So how so I iterate through a dictionary, looking for things, then remove them.... John
8
5902
by: David Cameron | last post by:
I noticed that using an HTMLInputRadioButton and specifying a value to be an empty string (""), this is overridden by ASP.Net which set the value of the control to be the same as the ID of the control. See the code below * Page.aspx: <%@ Page language="c#" Codebehind="Test.aspx.cs" AutoEventWireup="false" Inherits="Webspace.Test" %>
6
6110
by: Niyazi | last post by:
Hi all, What is fastest way removing duplicated value from string array using vb.net? Here is what currently I am doing but the the array contains over 16000 items. And it just do it in 10 or more minutes. 'REMOVE DUBLICATED VALUE FROM ARRAY +++++++++++++++++ Dim col As New Scripting.Dictionary Dim ii As Integer = 0
17
2716
by: Eric_Dexter | last post by:
def simplecsdtoorc(filename): file = open(filename,"r") alllines = file.read_until("</CsInstruments>") pattern1 = re.compile("</") orcfilename = filename + "orc" for line in alllines: if not pattern1 print >>orcfilename, line I am pretty sure my code isn't close to what I want. I need to be able
12
2068
by: sam | last post by:
hi all, i'm starting to put together a program to simulate the performance of an investment portfolio in a monte carlo manner doing x thousand iterations and extracting data from the results. i'm still in the early stages, and am trying to code something simple and interactive to get the percentages of the portfolio in the five different investment categories. i thought i'd get in with the error handling early so if someone types in...
20
5146
by: dmurray14 | last post by:
Hey guys, I'm a C++ newbie here - I've messed with VB, but I mostly stick to web languages, so I find C++ to be very confusing at times. Basically, I am trying to import a text file, but I want to do it word by word. I am confused as to how to do this. Typically, I would think it would make sense to try and input the words into strings, but for this application I need to use character arrays and pointers. So what's the best way to go...
3
3457
by: MLH | last post by:
Back in mid-2003, lucason posted a question about removing punctuation chars from a string. Suggested code was posted using Replace function. Could the FN below be easily modified for use with A97 which has no replace FN? xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx lucason View profile
33
2806
by: cesco | last post by:
Hi, say I have a string like the following: s1 = 'hi_cat_bye_dog' and I want to replace the even '_' with ':' and the odd '_' with ',' so that I get a new string like the following: s2 = 'hi:cat,bye:dog' Is there a common recipe to accomplish that? I can't come up with any solution...
209
8791
by: arnuld | last post by:
I searched the c.l.c archives provided by Google as Google Groups with "word input" as the key words and did not come up with anything good. C++ has std::string for taking a word as input from stdin. C takes input in 2 ways: 1) as a character, etchar() 2) as a whole line, fgets()
0
8888
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9176
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9113
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8097
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.