неверное преобразование символа * в int

0

Я застрял в этой части, и мне нужна помощь в исправлении ошибок компиляции в приведенном ниже коде. Я использую компилятор g++.

Сообщение об ошибке выглядит следующим образом: "неверное преобразование из символа âconst char * â в âintâ [-fpermissive]"

bool isRegistered(const Prefix* pre,int area,const char* publisher, int * pos)
{
int n,i=0,num,flag=0,low,high,pub;
n=*(pos);
while(pre->area[n]==area)
{
num=publisher[i]-48;

switch(pre->pubLen[n])
{
case 1:

num=publisher[i]-48;

В каждом случае проблема ниже.

low=((*pre).pubLow[n])-48;
high=(pre->pubHigh[n])-48; 
if((num>low)&&(num<high))
{
pub=num;
}
break;

case 2:
num=(publisher[i]-48)*10+(publisher[i+1]-48);
low=(pre->pubLow[n])-48;
high=(pre->pubHigh[n])-48;
if((num>low)&&(num<high))
{
pub=num;
}
break;

Определение префикса

struct Prefix {
    int  no;             // number of entries
    int  area[MAX];      // area elements
    char pubLow[MAX][8]; // low end of publisher range
    char pubHigh[MAX][8]; // high end of publisher range
    int  pubLen[MAX];    // no of chars in publisher string
};

Случай 3 и так далее....

  • 0
    Можете ли вы показать строку, которая дала ошибку?
  • 0
    Вам нужна помощь в написании кода, а не в его отладке
Показать ещё 10 комментариев
Теги:

1 ответ

0

Дайте определение pubLow

Также

**low=((*pre).pubLow[n])-48;
high=(pre->pubLow[n])-48; **

low - целое число, удалить ** до низкого и после 48; Такое, что оно становится

low=((*pre).pubLow[n])-48;
high=(pre->pubLow[n])-48;

Вот ваш код

 bool isRegistered(const Prefix* pre,int area, char* publisher, int * pos)
{
int n,i=0,num,flag=0,low,high,pub;
n=*(pos);
while(pre->area[n]==area)
{
num=publisher[i]-48;

switch(pre->pubLen[n])
{
case 1:

num=publisher[i]-48;
    low=atoi(((*pre).pubLow[n])-48);
high=atoi((pre->pubHigh[n])-48); 
if((num>low)&&(num<high))
{
pub=num;
}
break;

case 2:
num=(((publisher[i]-48)*10)+(publisher[i+1]-48));
low=atoi((pre->pubLow[n])-48);
high=atoi((pre->pubHigh[n])-48);
if((num>low)&&(num<high))
{
pub=num;
}
break;
  • 0
    Тем не менее, это показывает ошибку. Тот самый
  • 0
    Проверьте отредактированный код

Ещё вопросы

Сообщество Overcoder
Наверх
Меню