Server Help

Non-Subspace Related Coding - Problem with c++

hellzlaker - Thu Mar 13, 2008 3:05 pm
Post subject: Problem with c++
This is wierd but my program doesnt compile and this is what comiled log says
Code: Show/Hide
Compiler: Default compiler
Executing  g++.exe...
g++.exe "C:\Documents and Settings\Owner\Desktop\c++\Pokemon\Pokemon.cpp" -o "C:\Documents and Settings\Owner\Desktop\c++\Pokemon\Pokemon.exe"    -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include"  -I"C:\Dev-Cpp\include\c++\3.4.2\backward"  -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32"  -I"C:\Dev-Cpp\include\c++\3.4.2"  -I"C:\Dev-Cpp\include"   -L"C:\Dev-Cpp\lib"
C:\Documents and Settings\Owner\Desktop\c++\Pokemon\Pokemon.cpp: In function `int main()':
C:\Documents and Settings\Owner\Desktop\c++\Pokemon\Pokemon.cpp:22: error: no match for 'operator<<' in 'pok << p1'
C:\Documents and Settings\Owner\Desktop\c++\Pokemon\Pokemon.cpp:23: error: no match for 'operator<<' in 'pok << hp1'
C:\Documents and Settings\Owner\Desktop\c++\Pokemon\Pokemon.cpp:24: error: no match for 'operator<<' in 'pok << dmg1'
C:\Documents and Settings\Owner\Desktop\c++\Pokemon\Pokemon.cpp:25: error: no match for 'operator<<' in 'pok << evol1'

C:\Documents and Settings\Owner\Desktop\c++\Pokemon\Pokemon.cpp:26: error: no match for 'operator<<' in 'pok << p2'
C:\Documents and Settings\Owner\Desktop\c++\Pokemon\Pokemon.cpp:27: error: no match for 'operator<<' in 'pok << hp2'
C:\Documents and Settings\Owner\Desktop\c++\Pokemon\Pokemon.cpp:28: error: no match for 'operator<<' in 'pok << dmg2'
C:\Documents and Settings\Owner\Desktop\c++\Pokemon\Pokemon.cpp:29: error: no match for 'operator<<' in 'pok << evol2'
C:\Documents and Settings\Owner\Desktop\c++\Pokemon\Pokemon.cpp:30: error: no match for 'operator<<' in 'pok << p3'
C:\Documents and Settings\Owner\Desktop\c++\Pokemon\Pokemon.cpp:31: error: no match for 'operator<<' in 'pok << hp3'
C:\Documents and Settings\Owner\Desktop\c++\Pokemon\Pokemon.cpp:32: error: no match for 'operator<<' in 'pok << dmg3'
C:\Documents and Settings\Owner\Desktop\c++\Pokemon\Pokemon.cpp:33: error: no match for 'operator<<' in 'pok << evol3'
C:\Documents and Settings\Owner\Desktop\c++\Pokemon\Pokemon.cpp:34: error: no match for 'operator<<' in 'pok << p4'
C:\Documents and Settings\Owner\Desktop\c++\Pokemon\Pokemon.cpp:35: error: no match for 'operator<<' in 'pok << hp4'
C:\Documents and Settings\Owner\Desktop\c++\Pokemon\Pokemon.cpp:36: error: no match for 'operator<<' in 'pok << dmg4'
C:\Documents and Settings\Owner\Desktop\c++\Pokemon\Pokemon.cpp:37: error: no match for 'operator<<' in 'pok << evol4'
C:\Documents and Settings\Owner\Desktop\c++\Pokemon\Pokemon.cpp:38: error: no match for 'operator<<' in 'pok << p5'
C:\Documents and Settings\Owner\Desktop\c++\Pokemon\Pokemon.cpp:39: error: no match for 'operator<<' in 'pok << hp5'
C:\Documents and Settings\Owner\Desktop\c++\Pokemon\Pokemon.cpp:40: error: no match for 'operator<<' in 'pok << dmg5'

C:\Documents and Settings\Owner\Desktop\c++\Pokemon\Pokemon.cpp:41: error: no match for 'operator<<' in 'pok << evol5'

Execution terminated


here is the source code of the program
Code: Show/Hide
// pokemon legend http://iabot.iespana.es/juegos/pokemon/pokemon-rubi-zafiro.gif
#include <windows.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
    system("bin\\font.bat");
   
    SetConsoleTitle("A3 Pokemon");
   
    char name[80];
    char p1[80],p2[80],p3[80],p4[80],p5[80],mp[80];
    int hp1,hp2,hp3,hp4,hp5,hpmp;
    int dmg1,dmg2,dmg3,dmg4,dmg5,dmgmp;
    char evol1[80],evol2[80],evol3[80],evol4[80],evol5[80],evolmp[80];
   
    ifstream pok;
    pok.open("bin\\pokemon.a3");
    pok<<p1;
    pok<<hp1;
    pok<<dmg1;
    pok<<evol1;
    pok<<p2;
    pok<<hp2;
    pok<<dmg2;
    pok<<evol2;
    pok<<p3;
    pok<<hp3;
    pok<<dmg3;
    pok<<evol3;
    pok<<p4;
    pok<<hp4;
    pok<<dmg4;
    pok<<evol4;
    pok<<p5;
    pok<<hp5;
    pok<<dmg5;
    pok<<evol5;
    pok.close();



   
    cout<<"Tyron: Welcome to A3 Pokemon world my name is Tyron, whats yours?\n";
    cout<<"Answer: ";
    cin>>name;
    cout<<"\nTyrone: Oh "<<name<<" that pussy that ran away from Danglee Sack Town..";
    cout<<"\n\tWhat ever I'm here just to give you the shitiest pokemon out there, "<<p1;
   
   
    system("pause");
   
}




by what i understand is that it says my variables like p1 p2 are underclared? but i clearly declared them
k0zy - Thu Mar 13, 2008 4:03 pm
Post subject:
No.
It's trying to tell you that there's no operator << on pok.

Are you trying to read from the file, or write to it?

I guess you are trying to read... so the operator should be >> instead of <<
hellzlaker - Thu Mar 13, 2008 5:10 pm
Post subject:
f*ck im retarted thanks you very much i was playing around so much trying to fix it, and your right i was trying to read from file thank you very much biggrin.gif
tcsoccerman - Thu Mar 13, 2008 7:00 pm
Post subject:
you may want to look into structs but that is more advanced.
Bak - Thu Mar 13, 2008 8:23 pm
Post subject:
after you open a file check if it opened correctly ("if (pok.good())"), otherwise your program will crash if the file doesn't exist.
hellzlaker - Fri Mar 14, 2008 2:18 pm
Post subject:
Bak i did something different
Code: Show/Hide
    if (!pok)
    {
             cout<<"Game files are corrupt please go to www.a3studio.4t.com and redownload pokemon game\n";
             system("pause");
             return 0;
    }


Works fine
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group