Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 06-01-2006, 04:20 PM   #1 (permalink)
halloula
Registered User
 
Join Date: Jun 2006
Posts: 1
halloula is on a distinguished road
help with a program

i've done this program as part of my assigment but it won't compile and i got an error message saying a multipe definition of main plz have a look and try to help me solving this problem as i need it today
Code:
#include <iostream>
#include <string>
using namespace std;
int main() 
{
    string  id, 
            rest_of_the_line,
            name_and_address;

    // sub_header is a flag that indicates the sub header should be output
    bool sub_header = true;
    char gate;
    float total =0;
    const float amount_gate_A = 2.20;
    const float amount_gate_B = 2.80;
    const float amount_gate_C = 2.30;
    const float amount_gate_D = 3.80;
 
    while ( cin >> id >> gate )
    {
        getline(cin, rest_of_the_line);
        if ( gate == '@' )
        {
            if ( total > 0 )
            {
                // output the total
                cerr << "Total = " << total << endl;
            }
            // save the address as it will be overwritten in the next cin
            name_and_address = rest_of_the_line;
            // clear values of total and sub_header
            total = 0 ;
            sub_header = true;
        }
        else 
        {
            if ( sub_header )
            {
                cerr << " 1. Customer ID:"      << id               << endl;
                cerr << " 2. Name and Address:" << name_and_address << endl;
                cerr << " 3. Date        Time     Station    Amount"<< endl;
                sub_header = false;
            }


            // use substr to extract the date and time
           // The date is of length 11 and the rest is the time
            cerr << rest_of_the_line.substr(0,35 ) << "    " 
                 << rest_of_the_line.substr(36)  << "    " 
                 << gate << "        " ;

            if (gate == 'A')
            {
                cerr    << amount_gate_A;
                total   += amount_gate_A;
            }
            else if (gate == 'B')
            {
                cerr    << amount_gate_B;
                total   += amount_gate_B;
            }
            else if (gate == 'C')
            {
                cerr    << amount_gate_C;
                total   += amount_gate_C;
            }
            else if (gate == 'D')
            {
                cerr    << amount_gate_D;
                total   += amount_gate_D;
            }
            cerr << endl; 
        }
    }

    if ( total > 0 )
    {
        // output the total
        cerr << "Total = " << total << endl;
    }
    return 0;
}
halloula is offline   Reply With Quote
Old 06-01-2006, 06:29 PM   #2 (permalink)
kyoryu
Registered User
 
Join Date: Apr 2003
Posts: 34
kyoryu is on a distinguished road
It compiles fine for me. What's the exact message you're getting? How are you linking? What environment is this in? It sounds like a link problem to me.
kyoryu is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
need help with copying backwards rogue Standard C, C++ 9 04-24-2005 04:39 PM
simple question 'bout compiling c program if13121 Platform/API C++ 0 11-09-2004 10:36 PM
C++ Deadlock Detection Program Help... coolsc81 Standard C, C++ 2 10-26-2004 06:14 AM
Help on starting new program B00tleg Standard C, C++ 21 10-17-2004 12:58 PM


All times are GMT -8. The time now is 01:32 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting