Skip to content

Instantly share code, notes, and snippets.

@kaneshin
Created August 31, 2012 14:44
Show Gist options
  • Select an option

  • Save kaneshin/3553874 to your computer and use it in GitHub Desktop.

Select an option

Save kaneshin/3553874 to your computer and use it in GitHub Desktop.
memmove for vector
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int
main(int argc, char* argv[]) {
int i, n;
double *x;
n = 5;
x = (double *)malloc(n * sizeof(double));
for (i = 0; i < n; ++i)
{
x[i] = i + 1.123456;
}
memmove(x, x + 1, (n - 1) * sizeof(double));
for (i = 0; i < n; ++i)
{
printf("%f\n", x[i]);
}
free(x);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment