I am trying to solve this question where I have to spell numbers.
When I try to call my array of strings a
by reference, I get this error. But I get no error if I call it by value.
I don't know where is the rvalue coming from as my string elements should be considered lvalue.
#include <iostream>
#include <string>
using namespace std;
void spell(int n,string* &a){
if(n==0)
return;
spell(n/10,a);
cout<<a[n%10];
}
int main(){
int n;
cin>>n;
string a[10]{"zero ","one ","two ","three ","four ","five ","six ","seven ","eight ","nine "};
spell(n,a);
if(n<0)
return 0;
return main();
}