473,770 Members | 2,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

error checking by parsing thru a string

I was trying to find occurances of duplicate entries in a string
something like this
"1 + (2++34)-4*6/6*89"

So at first I tried this
String* str = S"1 + (2++34)-4*6/6*89";
int start;
int at;
int end;
int count;

end = str->Length;
start = 0;
Console::WriteL ine();
Console::Write( S"The string '++' occurs at position(s): ");
count = 0;
at = 0;
while((start <= end) && (at > -1)) {
count = end - start;
at = str->IndexOf(S"++ ", start, count);
if (at == -1) break;
Console::Write( S"{0} ", __box( at));
start = at+1;
}
Console::WriteL ine();

ok I can find ++ but what I wanted was instead of looking for
++ then -- then // thru some sort of loop
I was thinking

find_first_of( "++" "--" "**" "//" )

I know this doesn't work but can it be done simply?

thanks for any pointers (whoops wrong word) help :)

Jerry

Feb 2 '06 #1
1 1367
On Thu, 02 Feb 2006 15:19:28 GMT, sparks <js******@swbel l.net> wrote:
I was trying to find occurances of duplicate entries in a string
something like this
"1 + (2++34)-4*6/6*89"

So at first I tried this
String* str = S"1 + (2++34)-4*6/6*89";
int start;
int at;
int end;
int count;

end = str->Length;
start = 0;
Console::WriteL ine();
Console::Write( S"The string '++' occurs at position(s): ");
count = 0;
at = 0;
while((start <= end) && (at > -1)) {
count = end - start;
at = str->IndexOf(S"++ ", start, count);
if (at == -1) break;
Console::Write( S"{0} ", __box( at));
start = at+1;
}
Console::WriteL ine();

ok I can find ++ but what I wanted was instead of looking for
++ then -- then // thru some sort of loop
I was thinking

find_first_o f( "++" "--" "**" "//" )

I know this doesn't work but can it be done simply?

thanks for any pointers (whoops wrong word) help :)

Jerry


WELL maybe I was in a hurry and didn't think that its any combos.
DUH
find_first_of( "+*-/" )

so I will have to find it and check next to see if it repeats.
and flag that as an error.

man its toooo early in the morning
Jerry

Feb 2 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

67
4283
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. Unfortunately these ad hominem rhetorts are frequently introduced into purely technical discussions on the feasibility of supporting such functionality in C++. That usually serves to divert the discussion from the technical subject to a discussion of the...
1
2775
by: pbd22 | last post by:
hi. for some reason i am not able to navigate the dom. i keep getting the 'no properties' error but i think i am doing everything right. this is an XML response from an AJAX call. The ajax method to call the server code looks like this. i am passing a cookie as a parameter:
12
7192
by: jonatan | last post by:
Hello All, I am making a program and need the grt_main.c but i try to compile have the error c1004.Please help me how to solve it? Thank you. --------------------Configuration: pre - Win32 Debug-------------------- Compiling... pre.c c:\matlab6p5\work\penat\grt_main.c(661) : fatal error C1004: unexpected end of file found Error executing cl.exe.
3
4514
by: GazK | last post by:
I have been using an xml parsing script to parse a number of rss feeds and return relevant results to a database. The script has worked well for a couple of years, despite having very crude error-trapping (if it finds an error in one of the xml files, the script stops). Recently, the script has stopped working because one of the xml files is badly formed. So I decided to rewrite the script with better error trapping; the script should...
0
9453
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10254
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
10099
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
10036
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
9904
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
8929
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
5481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
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
2
3607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.