Herzlich Willkommen, lieber Gast!
  Sie befinden sich hier:

  Forum » C / C++ (ANSI-Standard) » compiler fehler bei verwendung von strlen

Forum | Hilfe | Team | Links | Impressum | > Suche < | Mitglieder | Registrieren | Einloggen
  Quicklinks: MSDN-Online || STL || clib Reference Grundlagen || Literatur || E-Books || Zubehör || > F.A.Q. < || Downloads   

Autor Thread - Seiten: > 1 <
000
08.07.2005, 22:08 Uhr
Skippy



so erstmal die fehlermeldung

no matching function for call to `strlen(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&'

CDev-Cpp\include\string.h:49 candidates are: size_t strlen(const char*)

expected primary-expression before "path"

expected `)' before "path"

no matching function for call to `strcat(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, const char[2])'

CDev-Cpp\include\string.h:41 candidates are: char* strcat(char*, const char*)

so nun der ausschnitt um dem es geht



C++:
  else {
    path = get_req;


    // Suche nach letztem Backslash
    std::string::size_type lastfile = path.rfind("/");
    std::string urlfile = path.substr(lastfile+1);
    ufilename = urlfile;


    // Suche nach einem Punkt
    if (urlfile.find(".") == std::string::npos)
       {
           ufilename ="index.html";

            //sprintf(path, "htdocs%s", path);
            if (path[strlen(path) - 1] != '/')
            strcat(path, "/");

       }

    std::string::size_type lastext = path.rfind(".");
    std::string urlext = path.substr(lastext+1);
    ufileext = urlext;

    }
  }





hat jemand ne idee worans liegt?
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
001
08.07.2005, 22:58 Uhr
Bruder Leif
dances with systems
(Operator)


Moin!

Wenn "path" ein std::string ist, liegts daran. Die C-Funktionen strlen, strcat etc. erwarten Zeiger auf char-Arrays. Unter C++ sollte man die std::strings verwenden, und die bringen ihre eigenen Methoden mit. Z.B. path.size() statt strlen(path). strcat(path, "/"); kannst Du durch path += "/"; ersetzen, usw...
--
Mit 40 Fieber sitzt man nicht mehr vor dem PC.
Man liegt im Bett.
Mit dem Notebook.
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
002
08.07.2005, 23:12 Uhr
Skippy



man bin ich blöd

danke für die hilfe

path ist ein std::string
dachte einfach wenn substr und rfind gehen wirds schon funktionieren
aber wie gesehen denkste

bis ich endlich die gewohnheiten von php losgeworden bin
werd ich wohl vorher verrückt

werds gleichmal probieren
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
Seiten: > 1 <     [ C / C++ (ANSI-Standard) ]  


ThWBoard 2.73 FloSoft-Edition
© by Paul Baecher & Felix Gonschorek (www.thwboard.de)

Anpassungen des Forums
© by Flo-Soft (www.flo-soft.de)

Sie sind Besucher: