| By Nekkid_Eye (Nekkid_Eye) on Friday, October 24, 2003 - 06:45 pm: Edit |
ok I am trying to write a program that converts roman numerals into arabic numbers, this is what i have so far.
however when i compile this to see if it is error free it doesn't work it gives me the error msgs of.
-------------------Configuration: C8P8 - Win32 Debug-------------------- Compiling... C8p8.cpp C:\Program Files\Microsoft Visual Studio\MyProjects\C8P8\C8p8.cpp(14) : error C2440: 'initializing' : cannot convert from 'char' to 'char []'
There are no conversions to array types, although there are conversions to references or pointers to arrays C:\Program Files\Microsoft Visual Studio\MyProjects\C8P8\C8p8.cpp(23) : error C2664: 'strcpy' : cannot convert parameter 2 from 'char' to 'const char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\Program Files\Microsoft Visual Studio\MyProjects\C8P8\C8p8.cpp(25) : error C2143: syntax error : missing ';' before 'switch'
C:\Program Files\Microsoft Visual Studio\MyProjects\C8P8\C8p8.cpp(26) : error C2450: switch expression of type 'char []' is illegal
Integral expression required Error executing cl.exe.
C8P8.exe - 4 error(s), 0 warning(s)
this is what i have so far with these errors
int main() {
char RomNum[100];
cout <<"enter a roman numeral" << endl;
cin.get(RomNum, 100);
cin.ignore(120, '\n'); char digit[10];
char digit2[10];
char digit3[10];
char digit4[10];
char digit5[10]; int arabic;
cout <<"enter a roman numeral" << endl;
cin.get(RomNum, 100);
cin.ignore(120, '\n');
strcpy(digit, RomNum[0])
switch(digit)
{
case 'I':
arabic = 1;
break;
}
cout << arabic << endl; return 0;
the one im particularly puzzled by is why i can't initial the char with the array
for example
i declare
char xx[] = romNum[1];
this give me an error
the general idea of this program is
eneral idea of this program is to char digit //declare this
RomNum = XXX //example of a char array
digit = RomNum[0] //basically break up the array into letters and store them into digit
switch (digit)
case "X" = 10
if (digit1 < digit2) digit 1 = -digit1
cout digit1
| By Mazzo (Mazzo) on Friday, October 24, 2003 - 11:23 pm: Edit |
c++. are you in AP comp sci? i thought it was java now.
im in an honors c++ class but its a joke. i have very little idea what the code above means
| By Andrew123s (Andrew123s) on Saturday, October 25, 2003 - 12:00 am: Edit |
Are you including string.h?
Also, as the compiler says, you can't do switch(digit) because digit is an array.
As for char xx[] = romNum[1], why are you setting an entire array to one value?
| By Nekkid_Eye (Nekkid_Eye) on Saturday, October 25, 2003 - 08:42 am: Edit |
thanks i screwed up shouldn't be initializing a char array into another array can only initialize one char
| By Chobo (Chobo) on Saturday, October 25, 2003 - 11:48 am: Edit |
Um not to be mean or anything... but the coding here is much too long and useless for a simple program to convernt Roman into arabic.
Report an offensive message on this page
E-mail this page to a friend
| Posting is currently disabled in this topic. Contact your discussion moderator for more information. |
| Administrator's Control Panel -- Board Moderators Only Administer Page |