I have an array of 1's and 0's which is compressed in such a way that when the number of 1's is greater than 10 it writes +n+ when n in the number of 1's and when the number of 0's is greater than 10 it writes -n- when n in the number of 0's otherwise it writes them as it is.
Now the issue is, I need to decompress the array to write it back to the file. But I can't find a way to convert the number of zeros or ones to integer. It keeps giving me an error which says initializing argument 1 of ‘int atoi(const char*) and another one on the same line which says invalid conversion from ‘char’ to ‘const char*’ I'm working in Linux. Here's a peice of my code
else if(str[i]=='+')
{
n=atoi(str[i+1]);
for(int j=0;j<n;j++)
{
strcat(temp,"1");
i=i+n-1;
}
}