Zobrazit předchozí téma :: Zobrazit následující téma |
Autor |
Zpráva |
koso
Založen: 28. 05. 2009 Příspěvky: 110
|
Zaslal: 16. říjen 2009, 19:22:10 Předmět: pomoc s chybou |
|
|
zasa ma trapi tato, pre mna zatial nepochopena chyba.Mozete mi ju objasnit?
kód: |
1>c:\users\koso\desktop\irrlicht-1.5\examples\loadtext\expat.cpp(28) : error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
1> c:\users\koso\desktop\proj\vc\include\ostream(653): could be 'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\users\koso\desktop\proj\vc\include\ostream(700): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\users\koso\desktop\proj\vc\include\ostream(738): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\users\koso\desktop\proj\vc\include\ostream(785): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\users\koso\desktop\proj\vc\include\ostream(909): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const signed char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\users\koso\desktop\proj\vc\include\ostream(916): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,signed char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\users\koso\desktop\proj\vc\include\ostream(923): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const unsigned char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\users\koso\desktop\proj\vc\include\ostream(930): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,unsigned char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\users\koso\desktop\proj\vc\include\ostream(170): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_ostream<_Elem,_Traits> &(__cdecl *)(std::basic_ostream<_Elem,_Traits> &))'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\users\koso\desktop\proj\vc\include\ostream(176): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_ios<_Elem,_Traits> &(__cdecl *)(std::basic_ios<_Elem,_Traits> &))'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\users\koso\desktop\proj\vc\include\ostream(183): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::ios_base &(__cdecl *)(std::ios_base &))'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\users\koso\desktop\proj\vc\include\ostream(190): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::_Bool)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\users\koso\desktop\proj\vc\include\ostream(210): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(short)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\users\koso\desktop\proj\vc\include\ostream(243): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(unsigned short)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\users\koso\desktop\proj\vc\include\ostream(263): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__w64 int)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\users\koso\desktop\proj\vc\include\ostream(288): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__w64 unsigned int)'
1> with
1> [ |
|
|
Návrat nahoru |
|
 |
rezna
Založen: 27. 07. 2007 Příspěvky: 2156
|
Zaslal: 16. říjen 2009, 19:31:55 Předmět: |
|
|
prepis na
kód: |
<< my_string.c_str() |
odhaduju
-----------------
jinak http://nopaste.ceske-hry.cz - je vhodne vlozit zdrojak kde ti to haze chybu |
|
Návrat nahoru |
|
 |
koso
Založen: 28. 05. 2009 Příspěvky: 110
|
Zaslal: 16. říjen 2009, 20:25:50 Předmět: |
|
|
teraz zasa toto
kód: |
error C2228: left of '.c_str' must have class/struct/union
1> type is 'const char *' |
|
|
Návrat nahoru |
|
 |
if.then
Založen: 13. 04. 2008 Příspěvky: 579
|
Zaslal: 16. říjen 2009, 20:32:52 Předmět: |
|
|
ZDROJAK!
bez toho to nepozname  _________________ For guns and glory, go to www.ceske-hry.cz.
For work and worry, execute VC++. |
|
Návrat nahoru |
|
 |
koso
Založen: 28. 05. 2009 Příspěvky: 110
|
Zaslal: 16. říjen 2009, 20:39:32 Předmět: |
|
|
je to z tutosa na jeden parser.ale stale to nechce ist
kód: |
#include <cstdlib>
#include <iostream>
#include <expat.h>
#define BUFFER_SIZE 30
using namespace std;
void startElement(void *userData, const char *name, const char **attrs)
{
int* level = (int*) userData;
(*level)++;
cout << "start element:" << name.c_str() << endl;
for(int i = 0; attrs[i] != NULL; i+=2) {
cout << "Attribute's name:" << attrs[i].c_str() << endl;
cout << "Attribute's value:" << attrs[i+1].c_str() << endl;
}
}
void characterData(void *userData, const XML_Char *buffer, int len)
{
int* level = (int*)userData;
string content(buffer, len);
if ((*level) == 4) {
cout << "element's data:" << content.c_str() << endl;
}
}
void endElement(void *userData, const char *name)
{
int* level = (int*) userData;
(*level)--;
cout << "end element:" << name.c_str() << endl;
}
int main()
{
//deklaracia potrebnych premennych
FILE* file;
XML_Parser parser;
char buffer[BUFFER_SIZE];
int isFinal;
int level;
size_t len;
int result;
//inicializacia parsera
parser = XML_ParserCreate(NULL);
XML_SetUserData (parser, &level);
XML_SetElementHandler(parser, startElement, endElement);
XML_SetCharacterDataHandler(parser, characterData);
//otvorenie input.xml suboru
file = fopen( "C:/Users/koso/Desktop/irrlicht-1.5/data/input.xml", "r");
if (!file) {
cout << "ERROR:nepodarilo sa otvorit subor, pravdepodobne neexistuje" << endl;
return 1;
}
//parsujeme data v subore
do {
len = fread(buffer, 1, sizeof(buffer), file);
isFinal = len - sizeof(buffer);
result = XML_Parse(parser, buffer, len, isFinal);
if (!result) {
cout << "ERROR PARSING:" << XML_ErrorString(XML_GetErrorCode(parser)).c_str() << " at line:" << XML_GetCurrentLineNumber(parser).c_str() << endl;
}
} while(!isFinal);
//upratanie
XML_ParserFree(parser);
fclose(file);
return 0;
system("pause");
} |
 |
|
Návrat nahoru |
|
 |
bolejt

Založen: 02. 05. 2009 Příspěvky: 45
|
Zaslal: 16. říjen 2009, 20:54:52 Předmět: |
|
|
jenze ty jsi ".c_str()" pridal snad vsude, kde jsi mohl. string a const char* je rozdil, zjednodusene string je trida a instance teto tridy mohou pouzivat metody (napr. .c_str(), tato metoda ti vrati const char*), kdezto const char* je jen pole znaku. _________________ Ball ball8; |
|
Návrat nahoru |
|
 |
koso
Založen: 28. 05. 2009 Příspěvky: 110
|
Zaslal: 16. říjen 2009, 21:06:06 Předmět: |
|
|
ja viem. tak potom plati ten prvy error |
|
Návrat nahoru |
|
 |
rezna
Založen: 27. 07. 2007 Příspěvky: 2156
|
Zaslal: 16. říjen 2009, 21:34:43 Předmět: |
|
|
neplati - tam kde je pouzite primo 'const char*' nebo 'char*' c_str() nepatri - ale tam kde je pouzite string to patri |
|
Návrat nahoru |
|
 |
koso
Založen: 28. 05. 2009 Příspěvky: 110
|
Zaslal: 16. říjen 2009, 21:56:33 Předmět: |
|
|
pomozte mi s tou chybou.prosim |
|
Návrat nahoru |
|
 |
rezna
Založen: 27. 07. 2007 Příspěvky: 2156
|
Zaslal: 16. říjen 2009, 22:06:07 Předmět: |
|
|
ctes??? - pisu - kde je char* tam c_str() nepouzivej - kde je string tam ho pouzivej |
|
Návrat nahoru |
|
 |
|