error checking by parsing thru a string

S

sparks

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::WriteLine();
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::WriteLine();

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
 
S

sparks

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::WriteLine();
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::WriteLine();

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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top