I am trying to get 4 digits from user in an array and then apply some encryption on it. i have written the function for it but i am having this error: request for member 'length' in 'f', which is of non-class type 'int [4]' Please tell me why i am facing this issue :( Here is my function:
int encryption(int num){
int a;
int b;
int c;
int d;
d= ((num%1000)%100)%10;
c = ((num%1000)%100)/10;
b = (num%1000)/100;
a = num/1000;
a = (a + 7)%10;
b = (b + 7)%10;
c = (c + 7)%10;
d = (d + 7)%10;
int f[] = {c,d,a,b};
int finalNumber = 0;
for (int i = 0; i < f.length; i++)
{
int num = f[i];
if (num != 0)
{
while (num > 0)
{
finalNumber *= 10;
num /= 10;
}
finalNumber += f[i];
}
else
{
finalNumber *= 10;
}
}
return finalNumber;
}
and main is:
int main()
{
cout<<"enter num";
cin>>num;
int enc=encryption(num);
cout<<"encrypted num is"<<enc;
return 0;
}