cin syntax error

error no match for operator> in std::cin>i

Page 1 of 1

8 Replies - 1776 Views - Last Post: 07 August 2009 - 03:03 PM Rate Topic: -----

#1 blaze212  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 50
  • Joined: 06-August 09

cin syntax error

Post icon  Posted 07 August 2009 - 01:28 PM

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	int i;
	cin > i;
	if ( i > 10 ){
		 cout << "It's greter than 10." << endl;
		 }
		 else {
			  cout << "It's not greater than 10." << endl;
			  }
	system("PAUSE");
	return EXIT_SUCCESS;
}


getting an error code. saying no match for operator > in std::cin>i

Mod Edit: Please use code tags when posting your code. Code tags are used like so => :code:

Thanks,
PsychoCoder :)

Is This A Good Question/Topic? 0
  • +

Replies To: cin syntax error

#2 ruddog  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 06-August 09

Re: cin syntax error

Posted 07 August 2009 - 01:35 PM

try cin>>i;
Was This Post Helpful? 0
  • +
  • -

#3 blaze212  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 50
  • Joined: 06-August 09

Re: cin syntax error

Posted 07 August 2009 - 01:39 PM

View Postruddog, on 7 Aug, 2009 - 12:35 PM, said:

try cin>>i;


now is highlighting the main. it is saying expected before int. i am using dev c++
Was This Post Helpful? 0
  • +
  • -

#4 paser  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 135
  • Joined: 30-May 09

Re: cin syntax error

Posted 07 August 2009 - 01:45 PM

set your return statement to return 0

return 0;

Was This Post Helpful? 0
  • +
  • -

#5 ruddog  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 06-August 09

Re: cin syntax error

Posted 07 August 2009 - 01:46 PM

#include <cstdlib>
#include <iostream>
using namespace std;
#define  EXIT_SUCCESS 0;

int main()
{
int i;
cin >> i;
if ( i > 10 ){
cout << "It's greter than 10." << endl;
}
else {
cout << "It's not greater than 10." << endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}


check it
Was This Post Helpful? 0
  • +
  • -

#6 sparkart  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 113
  • View blog
  • Posts: 690
  • Joined: 16-February 09

Re: cin syntax error

Posted 07 August 2009 - 01:55 PM

Your code compiles for me under Visual C++ 2008.
Was This Post Helpful? 0
  • +
  • -

#7 blaze212  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 50
  • Joined: 06-August 09

Re: cin syntax error

Posted 07 August 2009 - 01:58 PM

View Postruddog, on 7 Aug, 2009 - 12:46 PM, said:

#include <cstdlib>
#include <iostream>
using namespace std;
#define  EXIT_SUCCESS 0;

int main()
{
int i;
cin >> i;
if ( i > 10 ){
cout << "It's greter than 10." << endl;
}
else {
cout << "It's not greater than 10." << endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}


check it


did not work



View Postblaze212, on 7 Aug, 2009 - 12:55 PM, said:

View Postruddog, on 7 Aug, 2009 - 12:46 PM, said:

#include <cstdlib>
#include <iostream>
using namespace std;
#define  EXIT_SUCCESS 0;

int main()
{
int i;
cin >> i;
if ( i > 10 ){
cout << "It's greter than 10." << endl;
}
else {
cout << "It's not greater than 10." << endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}


check it


did not work



hey thanks i got it to work. let me ask u a question why do u have to put #define EXIT_SUCCESS 0;
Was This Post Helpful? 0
  • +
  • -

#8 Locke  Icon User is offline

  • Sarcasm Extraordinaire!
  • member icon

Reputation: 521
  • View blog
  • Posts: 5,596
  • Joined: 20-March 08

Re: cin syntax error

Posted 07 August 2009 - 02:01 PM

View Postblaze212, on 7 Aug, 2009 - 02:58 PM, said:

hey thanks i got it to work. let me ask u a question why do u have to put #define EXIT_SUCCESS 0;


Because it turns out that for your compiler, the EXIT_SUCCESS variable was not defined. It is only defined on some compilers. You could have just used return 0;

This post has been edited by Locke: 07 August 2009 - 04:14 PM

Was This Post Helpful? 0
  • +
  • -

#9 blaze212  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 50
  • Joined: 06-August 09

Re: cin syntax error

Posted 07 August 2009 - 03:03 PM

View PostLocke, on 7 Aug, 2009 - 01:01 PM, said:

View Postblaze212, on 7 Aug, 2009 - 02:58 PM, said:

hey thanks i got it to work. let me ask u a question why do u have to put #define EXIT_SUCCESS 0;


Because it turns out that for your compiler, that EXIT_SUCCESS variable was not defined. It is only defined on some compilers. You could have just used return 0;



Hey thanks for your info. i understan now.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1