i want to make a program which greets people differently according to their name, please dont get offended by the print statements it is just a prank for my friends. I am a beginner plz help. here's my code
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
string a;
cout<<"Please enter your name."<<endl;
getline(cin, a);
cin>>a>>endl;
if(a=="daksh" || a=="Daksh"){
cout<<"Chlaja bsdk 凸 ( ͡❛ 皿 ͡❛)凸"<<endl;
else if(a=="Harsh" || a=="harsh"){
cout<<"Bsdk MC behn K lode , machhar ki jhaat maki chut teri tatto ke saudagar (ง ͡❛ 皿 ͡❛)ง"<<endl;
else if(a=="Sparsh" || a=="sparsh"){
cout<<"Jahapana tussi geat ho , tofu kubul kro. /( ͡❛ ͜ʖ ͡❛)/"<<endl;
else {
cout<<"Hello ,dear"<<a<<endl;
}
}
}
}
return 0;
}
these are the errors , i have not posted all the errors because it is exceeding the word limit.
greetings.cpp: In function 'int main()':
greetings.cpp:12:11: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>' and '<unresolved overloaded function type>')
cin>>a>>endl;
~~~~~~^~~~~~
In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\iostream:40:0,
from greetings.cpp:1:
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\istream:120:7: note: candidate: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__istream_type& (*)(std::basic_istream<_CharT, _Traits>::__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
operator>>(__istream_type& (*__pf)(__istream_type&))
^~~~~~~~
In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\iostream:40:0,
from greetings.cpp:1:
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\istream:924:5: note: candidate: template<class _CharT, class _Traits, class _Tp> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&&, _Tp&)
operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x)
^~~~~~~~
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\istream:924:5: note: template argument deduction/substitution failed:
greetings.cpp:12:13: note: couldn't deduce template parameter '_Tp'
cin>>a>>endl;
^~~~
greetings.cpp:47:5: error: expected '}' before 'else'
else if(a=="Harsh" || a=="harsh"){
^~~~
greetings.cpp:49:5: error: expected '}' before 'else'
else if(a=="Sparsh" || a=="sparsh"){
^~~~
greetings.cpp:51:5: error: expected '}' before 'else'
else {
^~~~
greetings.cpp: At global scope:
greetings.cpp:55:9: error: expected declaration before '}' token
}
Aucun commentaire:
Enregistrer un commentaire