[SOLUCIONADO] BitConverter.getbytes es lo mismo que malloc?

Iniciado por proxy_lainux, Enero 31, 2014, 07:56:14 PM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Enero 31, 2014, 07:56:14 PM Ultima modificación: Agosto 19, 2014, 09:35:05 PM por Expermicid
me podria decir si BitConverter.getbytes es lo mismo que malloc?

por ejemplo en VB hacer esto...

Código: vbnet
Dim lowoffset() As Byte = BitConverter.GetBytes(curBig)


sera lo mismo que hacer....?

Código: c
BYTE *lowoffset = (BYTE*)malloc(sizeof(curBig))


curBig es un int64 = 322122547

o cual seria su equivalente en C?

You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
BitConverter.GetBytes Convierte los datos especificados en una matriz de bytes.

You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
malloc  Allocates a block of size bytes of memory, returning a pointer to the beginning of the block.

No es lo mismo.
No se si existe una funcion especifica para eso. Lo mas rapido es usar memcpy y copiar, por ejemplo, un int a un char array.

En VB6,  que no es lo mismo que .NET, recuerdo que había una funcion llamada string que funcionaba de la siguiente manera:

String(NumCaracteres, CaracterConElQueSeRellenaElBuffer)

Osea:

Buffer = String(100,chr(0)) ' Buffer de 100 byte rellenado con nulos.

También existe  la función Space (esta estoy seguro de que esta disponible para You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login)

You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login