mighty_squash
mighty_squash

Reputation: 143

Copying contents of a char array into another

How do I get the contents from one character buffer into another? For instance I have

char buffer[SMALLVALUE];
char new_buffer[BIGGERVALUE];

I'd like to copy the contents of buffer into new_buffer. What's the shortest way to do this?

Upvotes: 0

Views: 4422

Answers (1)

ouah
ouah

Reputation: 145899

#include <string.h>

memcpy(new_buffer, buffer, sizeof buffer);

Upvotes: 7

Related Questions