-
Help me
I need some help here, why this program is not working? What should be his correct form?
Code:
#include <iostream>
using namespace std;
struct database {
int Telefone();
};
int main()
{
string x;
cout<<"Testing\n";
cin>> x;
cin.ignore();
if ( x = Teste ) {
database Teste;
database *ptr;
teste.Telefone = 33327731
*ptr = &database;
cout<< ptr->Telefone
cin.get();
}
-
Use the "==" boolean operator, not the "=" assignment operator.
what is Teste ? is it a std::string or char array that was defined somewhere else (remember, variables have to be defined before they can be used)? Maybe you meant this
Code:
if ( x == "Teste" ) {
-
where to begin?
first, you are missing an } at the end.
second, the formatting is horrible to read.
third, you are comparing x with an undefined variable name (maybe you meant "Teste").
fourth, you are not allocating data for ptr.
fifth, you are assigning the value of *ptr to the address of database, (it should be *ptr = database).
sixth, is Telefone a function or a variable? You are defining it as a func but using it as a var.
EDIT: seveth, what AD said ;)