Answer the question
In order to leave comments, you need to log in
A char type argument is not compatible with a const char* type argument. How to fix?
I'm checking for a number. To do this, I create 2 arrays: one char, the other double. After I fill the char array and check if the entered characters are a number. If yes, then I convert them to double. But with the latter, it gives the error described in the title of the question.
double *Array(int size) {
char* gug = new char[size];
double* meow = new double[size];
bool digit = true;
for (int i = 0; i < size; i++) {
for (bool check = false; check != true;)
{
cin >> gug[i];
cout << endl;
if (!isdigit(gug[i]) && gug[0] != '-')
{
cout << "You need to enter a digit!" << endl;
digit = false;
break;
}
else
{
digit = true;
}
if (digit == true)
{
meow[i] = strtod(gug[i], NULL); //Вот тут ошибка
...
Answer the question
In order to leave comments, you need to log in
If you find out that the character is a digit, just subtract '0' from it.
if (digit == true) I do not recommend writing, you just need if (digit).
meow[i] = gug[i] - '0';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question