Answer the question
In order to leave comments, you need to log in
Comparison between pointer and integer. How to decide?
Task: display all numbers that start with "22"
Error (line 29): comparison between pointer and integer ('char *' and 'char')
if (s[0].pnumber == '2' && s[1 ].pnumber == '2')
What should I do to solve the problem?
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
int main ( )
{
int n;
cout<<"Enter number of subscribers: ";
cin>>n;
struct subscriber
{ int number;
char FIO[40];
char address[50];
char pnumber[10];
int duty;
}s[n];
int i;
for (i=0;i<n;i++)
{ cout<<"Number: "; cin>>s[i].number;
cout<<"FIO: "; cin>>s[i].FIO;
cout<<"Address: "; cin>>s[i].address;
cout<<"Phone number "; cin>>s[i].pnumber;
cout<<"Duty: "; cin>>s[i].duty;
}
float max=0;
int imax= -1;
cout<<"Result"<<endl;
for (i=0;i<n;i++)
if (s[0].pnumber == '2' && s[1].pnumber == '2')
if (s[i].duty> max ) { max= s[i].duty; imax=i;}
if (imax> -1)
{
cout<<"Number: "<<s[imax].number<<endl;
cout<<"FIO: "<<s[imax].FIO<<endl;
cout<<"Address: "<<s[imax].address<<endl;
cout<<"Phone number: "<<s[imax].pnumber<<endl;
cout<<"Duty: "<<s[imax].duty<<endl;
} else cout<<"No debtors were found"<<endl;
return 0;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question