close
Espaços nominais
Variantes
Ações

memmove

De cppreference.com
< c | string | byte

<metanoindex/>

 
 
 
Cordas de terminação nula de bytes
Funções
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Manipulação personagem
Original:
Character manipulation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Conversões para formatos numéricos
Original:
Conversions to numeric formats
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Manipulação de cadeia
Original:
String manipulation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Exame String
Original:
String examination
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Manipulação de memória
Original:
Memory manipulation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Diversos
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
<tbody> </tbody>
Definido no cabeçalho <string.h>
void* memmove( void* dest, const void* src, size_t count );
Cópias count personagens do objeto apontado por src ao objeto apontado por dest. Os objetos podem se sobrepor: copiar se passa como se os personagens foram copiadas para uma matriz caráter temporário e, em seguida, os personagens foram copiados da matriz para dest.
Original:
Copies count characters from the object pointed to by src to the object pointed to by dest. The objects may overlap: copying takes place as if the characters were copied to a temporary character array and then the characters were copied from the array to dest.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Parâmetros

dest -
ponteiro para o destino onde será feita a cópia
Original:
pointer to the memory location to copy to
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
src -
ponteiro para a origem de onde o bloco de memória será copiado
Original:
pointer to the memory location to copy from
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
count -
número de bytes a serem copiados
Original:
number of bytes to copy
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Valor de retorno

dest

Exemplo

#include <stdio.h>
#include <string.h>

void main(void) {
    char origem[100] = "Bananas, maças e mamão não fazem uma boa salada de frutas.";
    char destino[100] = {'\0'};       // inicia a variável destino com tamanho 0 (vazia).

    // Antes de mover o bloco de memória
    printf("origem : %s\n", origem);
    printf("destino: %s\n\n", destino);

    // move o conteúdo da memória origem para a variável destino
    memmove(destino, origem, strlen(origem));

    // Após mover o bloco
    printf("origem : %s\n", origem);
    printf("destino: %s\n\n", destino);

    // Diferentemente da função memcpy(), a função memmove() pode usar a mesma variável
    // como origem e destino. No exemplo abaixo, nós iremos remover a palavra 'não' da
    // sentença, movendo os bytes que estão à direita da palavra, 4 posições para à
    // esquerda, sobrepondo a palavra.
    memmove(destino+21, destino+26, strlen(destino)-4);

    // Depois de remover um espaço e a palavra ' não'
    printf("origem : %s\n", origem);
    printf("destino: %s\n\n", destino);
}

Saída:

// Antes de mover o bloco de memória
origem : Bananas, maças e mamão não fazem uma boa salada de frutas.
destino: 

// Após mover o bloco
origem : Bananas, maças e mamão não fazem uma boa salada de frutas.
destino: Bananas, maças e mamão não fazem uma boa salada de frutas.

// Depois de remover um espaço e a palavra ' não'
origem : Bananas, maças e mamão não fazem uma boa salada de frutas.
destino: Bananas, maças e mamão fazem uma boa salada de frutas.

Veja também

copia um buffer para outro
Original:
copies one buffer to another
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função) [edit]
C++ documentation for memmove