The amount of sentences

I am writing a program to show the amount of sentences I inputted. However, it showed an error of "no match for 'operator!=' in '(&std::cin)->std::basic_istream<_CharT, _Traits>::getline [with _CharT = char, _Traits = std::char_traits<char>](((char*)(&a)), 300) != -0x000000001' " for my code. Please help me out with my code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(){
char a[301];
int b=0,len;
while(cin.getline(a,300)!=EOF){
b++;
}
printf("%d\n",b);
return 0;
}
Member function getline returns reference to atd::cin. EOF is an integral constant. You can not compare them.
I think you meant simply

while ( cin.getline(a,300 ) ){


Thanks a lot. Problem solved. :)
Topic archived. No new replies allowed.