Thread: Program Error

  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    4

    Program Error

    I've been trying to get this program to work, but when I debug I get this error

    ***\processor.cpp(35) : error C2446: '!=' : no conversion from 'const unsigned int' to 'const char *'
    Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
    .\processor.cpp(35) : error C2040: '!=' : 'const char [9]' differs in levels of indirection from 'const unsigned int'***


    I am a beginner programming with C++, and only have basic knowledge. Here is my code

    Code:
    #include "header.h"
    
    using namespace std;
    
    	//Variables
    ifstream infile;
    ofstream outfile;
    char file[101];
    string line;
    int w = 0;
    int l = 0;
    int p = 0;
    
    	//Main Program
    int main()
    {
    	//Open files
     cout << "Please enter the location of the";
     cout << " history.";
     cout << endl;
     cin >> file;
     infile.open(file);
     while (!infile)
     {
    	 cout << "Cannot open the input file.  Please re-enter."; 
    	 cout << endl;
    	 cin >> file;
    	 infile.open(file);
     }
    	 
     outfile.open("results.txt");
    
     while (getline(infile, line))
     {
    	 if (line.find("Collects" != string::npos)
    		 w++;
    	 if (line.find("Loses" != string::npos)
    		 l++;
    	  if (line.find("Push" != string::npos)
    		 p++;
     }
    
     outfile << "Wins = " << w << endl;
     outfile << "Losses = " << l << endl;
     outfile << "Pushes = " << p << endl;
    
     infile.close();
     outfile.close();
    	
     return 0;
    }
    I am using this input text file.

    Stage # B506558848 - Blackjack 2009-02-13 14:51:22 (ET)
    ********** ( $30.00 in chips )
    -----------------------------------------------------------------------
    Hand 1-1: Bet $0.00 + Side Bet $0.00
    Hand 2-1: Bet $5.00 + Side Bet $0.00
    Hand 3-1: Bet $0.00 + Side Bet $0.00
    -----------------------------------------------------------------------
    Dealt to Hand 2-1: [ 5h 2s ]
    Dealt to Dealer: [ 2s H ]
    -----------------------------------------------------------------------
    Hand 2-1: HIT
    Dealt to Hand 2-1: [ 8s ]
    Hand 2-1: STAND
    -----------------------------------------------------------------------
    Dealer: Hit
    Dealt to Dealer: [ 3c ]
    Dealer: Hit
    Dealt to Dealer: [ 5s ]
    Dealer: Hit
    Dealt to Dealer: [ Ks ]
    -----------------------------------------------------------------------
    *** RESULT ***
    Dealer [ 2s 3c 5s Ks ] (20)
    Total Bet( $5.00 ), Win/Loss( -$5.00 )
    Hand 2-1 [ 5h 2s 8s ] (15) - Loses $5.00


    If someone could help me with what exactly the error is telling me to fix, I'd appreciate it.

  2. #2
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    the error the compiler is giving tells you the line number and a good detail of the message, and is talking about the "find" lines, such as: line.find("Collects" != string::npos)

    its complaining that it doesnt know what to do with an operator "!=" and operands of type string and integer. if you look closely at this line and your if statement youll notice you are just missing a closing bracket, i.e.: if ( line.find("Collects") != string::npos )

    edit: please note i havent looked at anything else in the code or input file besides line 35 which the compiler error is for.
    Last edited by nadroj; 05-02-2009 at 07:30 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 04:35 PM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM