Copy C String from Char Array to Another Char Array

Hello,

Let's say I have an array of char named arrayAlpha and it contains a C string. How may I copy this C string into another array of char? Let's say the second array is called arrayBeta.

char arrayAlpha[]; // Is this the first step?
char temp; // Do I create a temp variable?

Thanks for the help in advance!
Use standard function std::strcpy from header <cstring>. For example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <cstring>

int main()
{
   char s[] = "Hello World";
   char t[sizeof( s )];

   std::strcpy( t, s );

   std::cout << "s = " << s << std::endl;
   std::cout << "t = " << t << std::endl;

   return 0;
}
Topic archived. No new replies allowed.