Help meh please

Posts 1–15 of 39 · Page 1 of 3
Help meh please
Ok so I get 50 error when I compile this

[PHP]////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//Made by Naghal
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{
/////////////////////////////////////
int age = 0;
char name[] = "default";
char wdylif[] = "default";
char yes[] = "yes";
char no[] = "no";
char yesorno[] = "yesorno";
/////////////////////////////////////

cout << "Hi, was is your name?" << endl;
cin >> name;
cout << "Fine " << name << ", my name is Naghal." << endl;
cout << "I am 15 years old and you?" << endl;
cin >> age;
cout << "Ok, what do you like in life?" << endl;
cin >> wdylif;
cout << "Amazing, I love to do that too!" << endl;
cout << "Omg, do you want to be my friend?" << endl;
cin << yesorno;

if (yesorno = yes
{
cout << "Cool ur ma new best friendz!" << endl;
}
else if (yesorno = no
{
cout << "Aw comon pleaseee!!!" << endl;
}
else
{
cout << "Please, answer by yes or no." << endl;
}


system("pause"); //Let time of the player to read last answer

return 0;


}[/PHP]

Everything was fine and I was not getting any error until I added if(yesorno) part
Post your errors please.
They are in french I doupb you will understand...
Code:
Erreur	1	error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<char,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	2	error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<char,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	3	error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<char,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	4	error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<char,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	5	error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const unsigned char *)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<char,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	6	error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const unsigned char *)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<char,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	7	error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const unsigned char *)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<char,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	8	error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const unsigned char *)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<char,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	9	error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,signed char)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<char,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	10	error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,signed char)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<char,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	11	error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,signed char)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<char,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	12	error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,signed char)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<char,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	13	error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const signed char *)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<char,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	14	error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const signed char *)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<char,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	15	error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const signed char *)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<char,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	16	error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const signed char *)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<char,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	17	error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,_Elem)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<_Elem,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	18	error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,_Elem)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<_Elem,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	19	error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,_Elem)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<_Elem,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	20	error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,_Elem)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<_Elem,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	21	error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<_Elem,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	22	error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<_Elem,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	23	error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<_Elem,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	24	error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<_Elem,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	25	error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,char)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<char,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	26	error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,char)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<char,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	27	error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,char)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<char,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	28	error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,char)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<char,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	29	error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const char *)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<char,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	30	error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const char *)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<char,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	31	error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const char *)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<char,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	32	error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const char *)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<char,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	33	error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,char)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<_Elem,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	34	error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,char)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<_Elem,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	35	error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,char)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<_Elem,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	36	error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,char)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<_Elem,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	37	error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const char *)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<_Elem,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	38	error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const char *)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<_Elem,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	39	error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const char *)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<_Elem,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	40	error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const char *)'*: impossible de déduire l'argument modèle pour 'std::basic_ostream<_Elem,_Traits> &' à partir de 'std::istream'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	41	error C2676: '<<'*binaire : 'std::istream' ne définit pas cet opérateur ou une conversion vers un type acceptable pour l'opérateur prédéfini	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	32	SelfTalker
Erreur	42	error C2059: erreur de syntaxe*: ')'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	33	SelfTalker
Erreur	43	error C2440: '='*: impossible de convertir de 'char [4]' en 'char [8]'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	34	SelfTalker
Erreur	44	error C2143: erreur de syntaxe*: absence de ')' avant ';'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	34	SelfTalker
Erreur	45	error C2059: erreur de syntaxe*: ')'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	34	SelfTalker
Avertissement	46	warning C4390: ';'*: une instruction contrôlée a été trouvée vide*; est-ce ce que vous souhaitiez*?	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	35	SelfTalker
Erreur	47	error C2181: instruction else sans if correspondant non conforme	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	38	SelfTalker
Erreur	48	error C2440: '='*: impossible de convertir de 'char [3]' en 'char [8]'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	38	SelfTalker
Erreur	49	error C2143: erreur de syntaxe*: absence de ')' avant ';'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	38	SelfTalker
Erreur	50	error C2059: erreur de syntaxe*: ')'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	38	SelfTalker
Avertissement	51	warning C4390: ';'*: une instruction contrôlée a été trouvée vide*; est-ce ce que vous souhaitiez*?	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	39	SelfTalker
Erreur	52	error C2181: instruction else sans if correspondant non conforme	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	42	SelfTalker
I don't think yes or no should have a ";"

try replacing

Code:
if (yesorno = yes;)
with

if (yesorno = yes)

and also convert it to a string.
Fixed:

[php]
#include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{
/////////////////////////////////////
int age = 0;
char name[] = "default";
char wdylif[] = "default";
char yes[] = "yes";
char no[] = "no";
char yesorno[] = "yesorno";
/////////////////////////////////////

cout << "Hi, was is your name?" << endl;
cin >> name;
cout << "Fine " << name << ", my name is Naghal." << endl;
cout << "I am 15 years old and you?" << endl;
cin >> age;
cout << "Ok, what do you like in life?" << endl;
cin >> wdylif;
cout << "Amazing, I love to do that too!" << endl;
cout << "Omg, do you want to be my friend?" << endl;
cin >> yesorno;

if ( !strcmp(yesorno,"yes") )
{
cout << "Cool ur ma new best friendz!" << endl;
}
else if ( !strcmp(yesorno,"no") )
{
cout << "Aw comon pleaseee!!!" << endl;
}
else
{
cout << "Please, answer by yes or no." << endl;
}


system("pause"); //Let time of the player to read last answer

return 0;

}
[/php]

The 41 errors all came from putting << for cin instead of >>. You should pay closer attention. I also fixed your if statements, you should read up more on if/else statements, you almost had it.
Ok, now I would like it to bool it untill the player ask Yes or No to the question, how to do this?
Create a loop around that question until the answer is either yes or no.
Quote Originally Posted by Void View Post
Create a loop around that question until the answer is either yes or no.
I will try to make one because I don't know how to. If I don't get it I will ask you ^^

[php]#include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{
/////////////////////////////////////
int age = 0;
char name[] = "default";
char wdylif[] = "default";
char yes[] = "yes";
char no[] = "no";
char yesorno[] = "yesorno";
/////////////////////////////////////

cout << "Hi, was is your name?" << endl;
cin >> name;
cout << "Fine " << name << ", my name is Naghal." << endl;
cout << "I am 15 years old and you?" << endl;
cin >> age;
cout << "Ok, what do you like in life?" << endl;
cin >> wdylif;
cout << "Amazing, I love to do that too!" << endl;
cout << "Omg, do you want to be my friend?" << endl;
cin >> yesorno;

if ( !strcmp(yesorno,"yes") )
{
cout << "Cool ur ma new best friendz!" << endl;
}
else if ( !strcmp(yesorno,"no") )
{
cout << "Aw comon pleaseee!!!" << endl;
}
else
{
cout << "Please, answer by yes or no." << endl;
}

bool yesorno = false;

if (( !strcmp(yesorno,"yes") )) || ( !strcmp(yesorno,"no") ) = false);
{
bool yesorno = true;
}
system("pause"); //Let time of the player to read last answer

return 0;

} [/php]

I only get 3 errors ^^

Code:
Erreur	1	error C2040: 'yesorno'*: les niveaux d'indirection de 'bool' et de 'char [8]' sont différents	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	41	SelfTalker
Erreur	4	error C2059: erreur de syntaxe*: ')'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	43	SelfTalker
Erreur	3	error C2143: erreur de syntaxe*: absence de ';' avant '||'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	43	SelfTalker
Avertissement	2	warning C4390: ';'*: une instruction contrôlée a été trouvée vide*; est-ce ce que vous souhaitiez*?	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	43	SelfTalker
Sorry can't help with the errors, but I know how to make a simple loop

Well, to make a loop

just do


do {

whatever you want in the loop here

}while (while whatever you want it to loop for or w.e...)

for example, for a simple restarting program

[php]
#include <iostream>
#include <string>
using namespace std;
int main(){
string yesorno;
do { // do the following code
cout << "wanna display this again?\nyes or no" << endl;
cin >> yesorno;
}while(yesorno == 'yes'); // while yesorno == 'yes'
}
[/php] this will keep repeating as long as yesorno is yes...

if you want it to keep repeating as long as its neither yes or no then just

while(yesorno != 'yes' && 'no')
Quote Originally Posted by VvITylerIvV View Post
lets see what I can do here
[php]
#include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{
/////////////////////////////////////
int age = 0;
char name[] = "default";
char wdylif[] = "default";
char yes[] = "yes";
char no[] = "no";
char yesorno[] = "yesorno";
/////////////////////////////////////

cout << "Hi, was is your name?" << endl;
cin >> name;
cout << "Fine " << name << ", my name is Naghal." << endl;
cout << "I am 15 years old and you?" << endl;
cin >> age;
cout << "Ok, what do you like in life?" << endl;
cin >> wdylif;
cout << "Amazing, I love to do that too!" << endl;
cout << "Omg, do you want to be my friend?" << endl;
cin >> yesorno;

if ( !strcmp(yesorno,"yes") )
{
cout << "Cool ur ma new best friendz!" << endl;
}
else if ( !strcmp(yesorno,"no") )
{
cout << "Aw comon pleaseee!!!" << endl;
}
else
{
cout << "Please, answer by yes or no." << endl;
}

bool yesorno = false;

if (( !strcmp(yesorno,"yes") || !strcmp(yesorno,"no") = false);
{
bool yesorno = true;
}
system("pause"); //Let time of the player to read last answer

return 0;

}

[/php]

you had to many ')' in if (( !strcmp(yesorno,"yes") || !strcmp(yesorno,"no") = false);

I think it may be fixed, but I don't understand french so I can't read the errors... I'll run it in my compiler and edit this post


Well, to make a loop

just do


do {

whatever you want in the loop here

}while (while whatever you want it to loop for or w.e...)

for example, for a simple restarting program

[php]
#include <iostream>
#include <string>
using namespace std;
int main(){
string yesorno;
do {
cout << "wanna display this again?\nyes or no" << endl;
cin >> yesorno;
}while(yesorno == 'yes');
}
[/php] this will keep repeating as long as yesorno is yes...

if you want it to keep repeating as long as its neither yes or no then just

while(yesorno != 'yes' && 'no')
Uhmmmmmmm what was the point of half your thread?
edit: oh nao you edit it?
two erros letf with your code.

Quote Originally Posted by Kallisti View Post

Uhmmmmmmm what was the point of half your thread?
edit: oh nao you edit it?
And whats the point of your? At least hes trying to help.
Quote Originally Posted by Kallisti View Post

Uhmmmmmmm what was the point of half your thread?
edit: oh nao you edit it?
yeah, I don't know strcmp all to well, actually I never learned it... figured out my theory didn't work and deleted it... I still taught him the do{}while(); loop so I'm happy.


Quote Originally Posted by naghal707 View Post
two erros letf with your code.



And whats the point of your? At least hes trying to help.
and it didn't really help that much, it didn't fix anything so it had no point. I gotta agree with tails there lol. It was halfway pointless
here is the new code, I got the loop fine I think but there are synthax errors:

[php]#include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{
/////////////////////////////////////
int age = 0;
char name[] = "default";
char wdylif[] = "default";
char yes[] = "yes";
char no[] = "no";
char yesorno[] = "yesorno";
/////////////////////////////////////

cout << "Hi, was is your name?" << endl;
cin >> name;
cout << "Fine " << name << ", my name is Naghal." << endl;
cout << "I am 15 years old and you?" << endl;
cin >> age;
cout << "Ok, what do you like in life?" << endl;
cin >> wdylif;
cout << "Amazing, I love to do that too!" << endl;
cout << "Omg, do you want to be my friend?" << endl;
cin >> yesorno;

if ( !strcmp(yesorno,"yes") )
{
cout << "Cool ur ma new best friendz!" << endl;
}
else if ( !strcmp(yesorno,"no") )
{
cout << "Aw comon pleaseee!!!" << endl;
}
else
{
cout << "Please, answer by yes or no." << endl;
}


do{if ( !strcmp(yesorno,"yes") )
{
cout << "Cool ur ma new best friendz!" << endl;
}
else if ( !strcmp(yesorno,"no") )
{
cout << "Aw comon pleaseee!!!" << endl;
}
else
{
cout << "Please, answer by yes or no." << endl;
}}

while {!strcmp(yesorno,"yes") || !strcmp(yesorno,"no")}


system("pause"); //Let time of the player to read last answer

return 0;

} [/php]

Code:
Error	1	error C2059: syntax error*: '{'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	55	SelfTalker
Error	2	error C2143: syntax error*: missing ';' before '{'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	55	SelfTalker
Error3	error C2143: erreur de syntaxe*: missing ';' before '}'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	55	SelfTalker
ps:translated for you :P
No...Before he edited his post it was like 5 times as long -_- with random stuff talking about forum sections.
Quote Originally Posted by Kallisti View Post
No...Before he edited his post it was like 5 times as long -_- with random stuff talking about forum sections.
OOO THAT... yeah I don't know how that got there...

this is an excessively long post, teaching you how to search through errors. Read it if you want, the fixed code is in the end php code tag... if theres any way to hide this excessively long post, please tell me how...
 
Spoiler
doesn't work here and I don't know what else I could use...




Code:
Error	1	error C2059: syntax error*: '{'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	55	SelfTalker
Error	2	error C2143: syntax error*: missing ';' before '{'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	55	SelfTalker
Error3	error C2143: erreur de syntaxe*: missing ';' before '}'	c:\documents and settings\test\bureau\hacklearning\selftalker\selftalker\selftalker.cpp	55	SelfTalker
Well lets look at the errors, shall we.


syntax error*: '{' something to do with one of your '{'s

syntax error*: missing ';' before '{' missing a ';' before a '{'

syntax error*: missing ';' before '}' missing a ';' before a '}'

obviously, your missing ';'s before '{''}'s *not supposed to be a kirby but it kinda is*

lets look at your code for areas that have '{' or '}' without a ';' before them. and something to do with a misplaced '}'...

well, heres our code at the start
[php]#include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{
/////////////////////////////////////
int age = 0;
char name[] = "default";
char wdylif[] = "default";
char yes[] = "yes";
char no[] = "no";
char yesorno[] = "yesorno";
/////////////////////////////////////

cout << "Hi, was is your name?" << endl;
cin >> name;
cout << "Fine " << name << ", my name is Naghal." << endl;
cout << "I am 15 years old and you?" << endl;
cin >> age;
cout << "Ok, what do you like in life?" << endl;
cin >> wdylif;
cout << "Amazing, I love to do that too!" << endl;
cout << "Omg, do you want to be my friend?" << endl;
cin >> yesorno;

if ( !strcmp(yesorno,"yes") )
{
cout << "Cool ur ma new best friendz!" << endl;
}
else if ( !strcmp(yesorno,"no") )
{
cout << "Aw comon pleaseee!!!" << endl;
}
else
{
cout << "Please, answer by yes or no." << endl;
}


do{if ( !strcmp(yesorno,"yes") )
{
cout << "Cool ur ma new best friendz!" << endl;
}
else if ( !strcmp(yesorno,"no") )
{
cout << "Aw comon pleaseee!!!" << endl;
}
else
{
cout << "Please, answer by yes or no." << endl;
}}

while {!strcmp(yesorno,"yes") || !strcmp(yesorno,"no")}


system("pause"); //Let time of the player to read last answer

return 0;

}
[/php]

half of this doesn't include '{'s

[php]

if ( !strcmp(yesorno,"yes") )
{
cout << "Cool ur ma new best friendz!" << endl;
}
else if ( !strcmp(yesorno,"no") )
{
cout << "Aw comon pleaseee!!!" << endl;
}
else
{
cout << "Please, answer by yes or no." << endl;
}


do{if ( !strcmp(yesorno,"yes") )
{
cout << "Cool ur ma new best friendz!" << endl;
}
else if ( !strcmp(yesorno,"no") )
{
cout << "Aw comon pleaseee!!!" << endl;
}
else
{
cout << "Please, answer by yes or no." << endl;
}}

while {!strcmp(yesorno,"yes") || !strcmp(yesorno,"no")}


system("pause"); //Let time of the player to read last answer

return 0;

}
[/php]

you just added a loop, your first one. Let's check and make sure those are coded right. hmm NOPE! found the first error.

The correct syntax is do{}while(); you have do{while()}

lets quickly fix that

[php]#include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{
/////////////////////////////////////
int age = 0;
char name[] = "default";
char wdylif[] = "default";
char yes[] = "yes";
char no[] = "no";
char yesorno[] = "yesorno";
/////////////////////////////////////

cout << "Hi, was is your name?" << endl;
cin >> name;
cout << "Fine " << name << ", my name is Naghal." << endl;
cout << "I am 15 years old and you?" << endl;
cin >> age;
cout << "Ok, what do you like in life?" << endl;
cin >> wdylif;
cout << "Amazing, I love to do that too!" << endl;
cout << "Omg, do you want to be my friend?" << endl;
cin >> yesorno;

if ( !strcmp(yesorno,"yes") )
{
cout << "Cool ur ma new best friendz!" << endl;
}
else if ( !strcmp(yesorno,"no") )
{
cout << "Aw comon pleaseee!!!" << endl;
}
else
{
cout << "Please, answer by yes or no." << endl;
}


do{if ( !strcmp(yesorno,"yes") )
{
cout << "Cool ur ma new best friendz!" << endl;
}
else if ( !strcmp(yesorno,"no") )
{
cout << "Aw comon pleaseee!!!" << endl;
}
else
{
cout << "Please, answer by yes or no." << endl;
}}

}while {!strcmp(yesorno,"yes") || !strcmp(yesorno,"no")


system("pause"); //Let time of the player to read last answer

return 0;

}
[/php]

by running this, the second two errors are still found. Well, using my handy dandy visual c++ ultimate edition, the errors are pointed out to me. You haev while { )... uhoh! and then, VS c++ points out that near the middle, you have an extra '}' seeing as it's extra, it ends the do loop... OH NOES. Well, now both those errors are fixed, this is what we get

[php]
#include <iostream>

using namespace std;

int main()
{
/////////////////////////////////////
int age = 0;
char name[] = "default";
char wdylif[] = "default";
char yes[] = "yes";
char no[] = "no";
char yesorno[] = "yesorno";
/////////////////////////////////////

cout << "Hi, was is your name?" << endl;
cin >> name;
cout << "Fine " << name << ", my name is Naghal." << endl;
cout << "I am 15 years old and you?" << endl;
cin >> age;
cout << "Ok, what do you like in life?" << endl;
cin >> wdylif;
cout << "Amazing, I love to do that too!" << endl;
cout << "Omg, do you want to be my friend?" << endl;
cin >> yesorno;

if ( !strcmp(yesorno,"yes") )
{
cout << "Cool ur ma new best friendz!" << endl;
}
else if ( !strcmp(yesorno,"no") )
{
cout << "Aw comon pleaseee!!!" << endl;
}
else
{
cout << "Please, answer by yes or no." << endl;
}


do{
if ( !strcmp(yesorno,"yes") )
{
cout << "Cool ur ma new best friendz!" << endl;
}
else if ( !strcmp(yesorno,"no") )
{
cout << "Aw comon pleaseee!!!" << endl;
}
else
{
cout << "Please, answer by yes or no." << endl;
}

}while (!strcmp(yesorno,"yes") || !strcmp(yesorno,"no");


system("pause"); //Let time of the player to read last answer

return 0;

} [/php]

Hmm... still get an error, lets check out that while loop again. Double check then triple check right? You're missing a ')' at the end of that.... that just can't be, this is c++ after all. Lets fix that, andddd

[php]
#include <iostream>

using namespace std;

int main()
{
/////////////////////////////////////
int age = 0;
char name[] = "default";
char wdylif[] = "default";
char yes[] = "yes";
char no[] = "no";
char yesorno[] = "yesorno";
/////////////////////////////////////

cout << "Hi, was is your name?" << endl;
cin >> name;
cout << "Fine " << name << ", my name is Naghal." << endl;
cout << "I am 15 years old and you?" << endl;
cin >> age;
cout << "Ok, what do you like in life?" << endl;
cin >> wdylif;
cout << "Amazing, I love to do that too!" << endl;
cout << "Omg, do you want to be my friend?" << endl;
cin >> yesorno;

if ( !strcmp(yesorno,"yes") )
{
cout << "Cool ur ma new best friendz!" << endl;
}
else if ( !strcmp(yesorno,"no") )
{
cout << "Aw comon pleaseee!!!" << endl;
}
else
{
cout << "Please, answer by yes or no." << endl;
}


do{
if ( !strcmp(yesorno,"yes") )
{
cout << "Cool ur ma new best friendz!" << endl;
}
else if ( !strcmp(yesorno,"no") )
{
cout << "Aw comon pleaseee!!!" << endl;
}
else
{
cout << "Please, answer by yes or no." << endl;
}

}while (!strcmp(yesorno,"yes") || !strcmp(yesorno,"no"));


system("pause"); //Let time of the player to read last answer

return 0;

}
[/php] fixed!


*note, if you don't have visual c++ 2010 then the errors will most likely NOT be pointed out for you. It's a REALLY helpful addition, and I'd highly recommend getting it... (visual c++ ULTIMATE is $16,000 so maybe not ultimate...) but express also displays errors I believe.*
Posts 1–15 of 39 · Page 1 of 3

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us