Thread: Error Messages...

  1. #1
    Registered User
    Join Date
    Apr 2013
    Posts
    1

    Error Messages...

    hello everyone. im new to the forums and i dont really know how to use tags(sorry about that, administrator). anyway i have a really annoying problem when i try to compile this using Borland- i get like 6 error all saying "type mismatch in parameter..." and "cannot convert int to const char". I'd appreciate some help. Thanks
    Code:
    #include<iostream>
    #include<conio>
    #include<stdio>
    #include<string>
    
    
    class tourist{
    
    
     private:
    
    
       char namet[5];
       char tot[5];
       char fromt[5];
       char typet;
       int ID;
       int distance;
       int charge;
    
    
    
    
     public:
    
    
       void getdata(){
       cout<<"Enter ID:, then name(separated by enter key)";
       cin>>ID;
       cin.get(namet,5);
       cout<<"\nEnter to/from:(type destination, hit enter, type origin, hit enter)";
       cin.getline(tot,5);
       cin.get(fromt,5);
       cout<<"\nEnter distance:";
       cin>>distance;
       cout<<"\nEnter type:";
       gets(typet);
          }
    
    
       void calccharge(){
           if(strcmp(typet,'e'))
          charge=distance*30;
          else charge=distance*20;
            }
    
    
       void display(){
           cout<<"\nDetails are"<<"\t"<<ID<<"\t"<<namet<<"\t"<<typet<<"\t"<<tot<<"\t"<<fromt<<"\t"<<charge;
              }
    };
    
    
    
    
    void main(){
    
    
         tourist t1;
         cout<<"\n";
         t1.getdata();
         t1.calccharge();
         t1.display();
    
    
    
    
     }
    PS the variable names are a bit messed up cause i changed them since i thought i was using a reserved word or something...

  2. #2
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Just a few things I noticed.
    <conio> and <stdio> are not standard headers.
    gets() doesn't work with single characters, same with strcmp().
    Kurt

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Change void main to int main: SourceForge.net: Void main - cpwiki
    Change your char arrays to std::string.
    Do not ever use gets. Use std::getline.
    Compare std::string with the == operator.
    Indent properly: http://sourceforge.net/apps/mediawik...le=Indentation
    Get a modern compilers (GCC or Clang recommended).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Two error messages that I need help with.
    By Trey Brumley in forum C++ Programming
    Replies: 6
    Last Post: 11-19-2012, 11:58 AM
  2. error messages i need help please!
    By vodka9er in forum C++ Programming
    Replies: 2
    Last Post: 11-19-2007, 02:01 AM
  3. MANY MANY error messages
    By vrek in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2007, 10:58 PM
  4. XP error messages
    By chris1985 in forum Windows Programming
    Replies: 2
    Last Post: 01-12-2005, 02:37 PM
  5. Help with error messages
    By chris1985 in forum Windows Programming
    Replies: 1
    Last Post: 01-11-2005, 03:39 PM