Moderadores: andre_luis, 51, guest2003, Renie
Francesco escreveu:Um colega aqui no serviço utilizou um PIC18 com ethernet integrado, e reclamou bastante. Mas no final, funcionou.
static char *client_postval;
char strbuf[5];
itoa(strlen(client_postval),strbuf,10);
fabim escreveu:poisé TCP, isso eu ja sabia.
Só que o compilador que eu estou usando ta correndo destes comandos!!rsrs
porexempru
- Código: Selecionar todos
static char *client_postval;
char strbuf[5];
itoa(strlen(client_postval),strbuf,10);
eu nunca vi este comandado, estou aqui grogrando e achei n explicações para a mesma coisa, só que não consegui ententer.
C sabe me dizer o que o comando faz ? o respo eu me viro!!
Abraços
Fabim
tcpipchip escreveu:char strbuf[5];
itoa(strlen(client_postval),strbuf,10);
Pelo que entendi, pega o tamanho da string apontada por client_postval (até encontrar NULL) e transforma e joga em ASCII jogando no endereço apontado por strbuf (vector) com NULL no final e 10 é a base.
char letras[]="eu fui e voce";
char resu[6];
char * B16toChar(unsigned int i, char *buf)
{
char *p;
p = buf + 5;
*p = 0;
if (i < 0)
{
do
*p-- = '0' - i % 10;
while ((i /= 10) != 0);
*p-- = '-';
}
else
{
do
*--p = '0' + i % 10;
while ((i /= 10) != 0);
}
return p;
}
void pegahex(unsigned short *intvar, char *arraybytes){
unsigned short num = 2, temp=0;
arraybytes = arraybytes + 6;
*arraybytes = '\0';
arraybytes--;
while(num){
temp = *intvar;
temp &= 0x0f;
if(temp<=9)
temp = temp + '0';
else
temp = temp + ('A'-10);
*arraybytes = temp;
arraybytes--;
temp = *intvar;
temp = (temp >> 4) & 0x0f;
if(temp<=9)
temp = temp + '0';
else
temp = temp + ('A'-10);
*arraybytes = temp;
arraybytes--;
intvar++;
num--;
}
}
unsigned int STRLENGTOHEX(char *a, char *buffer, short radix){
unsigned int tamanho=0;
char temp[6];
while(*a){ //descobre tamanho string até '\0'
a++;
tamanho++;
}
switch(radix){//print decimal ou hex
case 10:
B16toChar(tamanho, &temp);
break;
case 16:
pegahex(tamanho, &temp);
break;
}
}
void main() {
while(1){
STRLENGTOHEX(letras,resu,16);
}
}
char *itostr(unsigned int i, char base)
{
const char *hex = "0123456789abcdef";
static char tmp[sizeof(int)*8+1];
char j,k;
tmp[j = sizeof(int)*8]=0;
if(i)
for (k=0; i; i=i/base, k++)
tmp[--j] = hex[i%base];
else
{
tmp[--j] = '0';
k=1;
}
while(j&1)
tmp[--j] = '0';
return tmp + j;
}
unsigned int strtoi(char *p,char base)
{
const char *hex = "0123456789abcdef";
unsigned int i,j;
for(i=0;*p;p++)
{
i=i*base;
for(j=0;j!=base;j++)
if(hex[j]==*p)
i+=j;
}
return i;
}
Usuários navegando neste fórum: Nenhum usuário registrado e 1 visitante