Possible Duplicate:
Using strtok with a std::stringerreur: conversion non valide de 'const char *' pour 'char *'
#include<iostream>
#include <string>
#include <string.h>
using namespace std;
int main()
{
string s("hello hi here whola");
string background;
char *strval;
char* tok = strtok_r(s.c_str()," ",&strval);
while(tok !=NULL)
{
cout << tok <<"\n";
if (tok == "&")
background = tok;
else
{
statements1;
statement2.. ;
}
tok = strtok_r(NULL, " ",&strval);
}
return 0;
}
sortie:
new.cpp: In function ‘int main()’:
new.cpp:13:47: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
/usr/include/string.h:359:14: error: initializing argument 1 of ‘char* strtok_r(char*, const char*, char**)’ [-fpermissive]
pourquoi avez-vous marqué ce C? Avez-vous l'impression que C et C++ sont le même langage? –
C'est vraiment horrible. Choisissez une langue en premier, je recommande C++. – Andro
Pourquoi les utilisateurs l'identifient-ils en tant que c et C++ lorsqu'ils sont en différentes langues? –