grazie per la risposta, ........... non va neanche così, ho provato di tutto
string.c_str()http://www.cplusplus.com/reference/string/string/c_str/atoihttp://www.cplusplus.com/reference/clibrary/cstdlib/atoi/boost::lexical_cast works pretty well. #include <boost/lexical_cast.hpp>
http://stackoverflow.com/questions/228005/alternative-to-itoa-for-converting-integer-to-string-clibrerie caricate#include <String.h>
#include <Iostream.h>
#include <stdio.h>
#include <stdlib.h>
#include <cstring.h>
ho sempre un errore o di char, o di conversione, o di inizializzazione ecc
nella tua correzione ho provato così:
String D3 = "46";
char * thisChar = D3.toCharArray() ;
int a = atoi(thisChar);
con questo errore:
error: no matching function for call to 'String::toCharArray()'
C:\Programmi\arduino-0022\hardware\arduino\cores\arduino/WString.h:80: note: candidates are: void String::toCharArray(char*, unsigned int)
vedendo su
http://arduino.cc/en/Reference/StringToCharArraystring.toCharArray(buf, len)
Parameters
string: a variable of type String
buf: the buffer to copy the characters into (char [])
len: the size of the buffer (unsigned int)
mettendo i parametri
String D3 = "46";
char * thisChar = D3.toCharArray(2,2) ;
int a = atoi(thisChar);
errore:
sketch_oct25a:109: error: invalid conversion from 'int' to 'char*'
sketch_oct25a:109: error: initializing argument 1 of 'void String::toCharArray(char*, unsigned int)'
sketch_oct25a:109: error: void value not ignored as it ought to beciao
