newb :S

hey all im seriously new to C++ and struggling a bit.
im trying to write some code to change roman numerals to Arabic numbers.

this is what i have done so far...

#include <iostream>
#include <string>

int main
string roman;
const string con[8] = [nill,I,II,III,IV,V,VI,VII,VIII,IX};

cout<<"which Roman numeral shall be converted:";
cin>>roman;
roman.touper();


for (size_t i=0; i<str.length(); ++i)
cout<< toupper(str[i],loc);



int i = 0
while(i!=10) {

if(con[i] ==roman){
break;
}

i++;

}

cout << i << endl;

return 0;
}

i just want to know if im in the right direction and if anyone can give me any tips.
thanks all
close, just a few small errors let me just point out

you should be using namespace std;, or be useing a lot of std::'s
con has 10 strings, not 8.
nill should be capitolized, as you will be comparing it to a capitalized string
string does not have a toupper member, so delete that line
your string is called roman, not str, so change that in your for loop.
you don't want to just output capitols, but replace each letter with it's capitol, so cout<< toupper(str[i],loc); should be roman[i] = toupper(roman[i]);
you're missing a semicolon after int i = 0 (a common mistake, one I make far to often)
Last edited on
thanks for that, some errors still but a vast improvement lol.
appreciate it Gumbercules
When initializing strings you should use double quotes:
const string con[] = {"nill","I","II","III",/* ... */};
In the same line you have [ instead of {
Also, main needs to include an empty parameter list and an opening bracket.

1
2
int main(){
...
Topic archived. No new replies allowed.