I understand strings/chars, just not all the ways to use them. I am trying to use chars to do the roman numerals problem, because as an array, chars would be a bit easier to assign the letters to(at least in my view) and because they are what I understand a little better. I am not doing this as homework, or to complete the problem, just to give myself examples I can understand and reread for myself later, and to give myself ways around errors I may have. However, I keep getting errors, and I am not sure how to use getline in this, or whether it would make a difference.
Code:
int main(){
int y, x, C,d;
char ett[10], out[50];
cin>>ett;
y = strlen(ett); //length of string ett
C = atoi(ett);//making the inter the value in the string
for(x = 0; x < C;x = x + 1){out[x] = 'I';}//makes each array digit = I for the number size.
for(x = 0; x < 50;x = x + 1){if (out[x] == 'I'){d = d + 1;}}// SHOULD make int d change + 1 based on the amount of 'I' in string out
cout<<out<<" "<<d;
}
if input is 2, output should be "II 2". The output for the first is always right(although throughout doing this, it has also had at the end extra symbols) but the value for the second will not work.