my noob program doesnt work

This is a discussion on my noob program doesnt work within the C++ Programming forums, part of the General Programming Boards category; im very confused my noob program dont work and im geting angry help please i beg!! Code: #include <iostream> using ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Location
    Brasil
    Posts
    220

    my noob program doesnt work

    im very confused my noob program dont work and im geting angry
    help please i beg!!
    Code:
    #include <iostream>
    using namespace std;
    struct database {
               string Telefone();
               string Endereco();
               string Email();
                };
    int main()
    {
    do {
                    int a;
                    a = 0;
                    string name;
                    cout<<"Voce deseja procurar os dados de qual pessoa?\nPS:para aparecer todos digite: TODOS\n";
                    cin>> name;
                    cin.ignore();
                    switch ( name ) {
                           case FelipeFarinon:
                                database FelipeFarinon;
                                FelipeFarinon.Telefone = 33327731
                                FelipeFarinon.Enderešo = Rua Luiz Voelcker 30, AP-504
                                FelipeFarinon.Email = felipesev@hotmail ou felipe.farinon@gmail
                                cout<<"Telefone: <<Felipe Farinon.Telefone<<\n";
                                cout<<"Endereco: <<Felipe Farinon.Endereco<<\n";
                                cout<<"Email: <<Felipe Farinon.Email<<\n";
                                break;
                                case TODOS:
                                     database Felipe Farinon;
                                FelipeFarinon.Telefone = 33327731
                                FelipeFarinon.Enderešo = Rua Luiz Voelcker 30, AP-504
                                FelipeFarinon.Email = felipesev@hotmail ou felipe.farinon@gmail
                                cout<<"Telefone: <<Felipe Farinon.Telefone<<\n";
                                cout<<"Endereco: <<Felipe Farinon.Endereco<<\n";
                                cout<<"Email: <<Felipe Farinon.Email<<\n";
                                     break;
                                     default:
                                             cout<<"Voce digitou um nome invalido ou inexistente\n";
                                             break;
                                             }         
                                             }while (a == 0);
    }
    where is the problem?

  2. #2
    Registered User
    Join Date
    Oct 2005
    Location
    Brasil
    Posts
    220
    oh i forgot the

    cin.get();

    at the end

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    7,319
    What is the problem? Are there compiler errors? What are they? Is it just not working how you'd expect it to? Why?

    The first thing I noticed is that you are trying to do a switch with a string. The switch only works with integral data types. You need to do a series of if/else if statements. Also, when checking a string variable like name against a literal string like "FelipeFarinon", you must put the literal string in double quotes.

    I also notice many missing semi-colons, and some extra () in your struct's members' declarations. Try starting with a much smaller program and getting it to compile one step at a time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. i cant get this program to work
    By asmaa in forum C++ Programming
    Replies: 9
    Last Post: 02-10-2009, 02:37 AM
  2. threaded program doesn't work?
    By OcTO_VIII in forum Linux Programming
    Replies: 1
    Last Post: 12-11-2003, 11:37 AM
  3. The Bludstayne Open Works License
    By frenchfry164 in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 11-26-2003, 10:05 AM
  4. Can't get program to work
    By theirishrover12 in forum C Programming
    Replies: 1
    Last Post: 06-08-2002, 11:10 AM
  5. how does this program work
    By ssjnamek in forum C++ Programming
    Replies: 2
    Last Post: 01-02-2002, 12:48 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21