Is there a way that you can convert a roman numeral to a decimal number? for example is there a way to break a string into 1 letter at a time so I can verify 1 letter at a time so I can put it in a casestatement
Printable View
Is there a way that you can convert a roman numeral to a decimal number? for example is there a way to break a string into 1 letter at a time so I can verify 1 letter at a time so I can put it in a casestatement
Sure, you can do that.
That code does nothing but you should get the idea how to walk through a string. You have a pointer to a series of characters. When you dereference the pointer you get a single character. So to get the second character I add one to the pointer address and then dereference. Hope that helped.Code:char *lpString = "Hello World";
char firstChar = *lpString;
char secondChar = *(lpString + 1);
switch( firstChar )
{
case 'X':
case 'x':
// blah..
break;
}
EDIT:
You'll want this in a loop and you'll want to check for the '\0' character because strings are null-terminated.
If you are using type string, you can use index operator [].
ggCode:string str = "Hello Word!";
char first = str[0].
I was not aware you could use the index operator on a string type. I am glad I read this thread ;)Quote:
Originally posted by Codeplug
If you are using type string, you can use index operator [].
ggCode:string str = "Hello Word!";
char first = str[0].
do a board search. Roman numeral conversions crop up quite often.