c copy string
char *str = "Hello World!";
char copy[64]; // or 'char *copy = malloc(strlen(str) + 1);'
strcpy(copy, str);
c copy string
char *str = "Hello World!";
char copy[64]; // or 'char *copy = malloc(strlen(str) + 1);'
strcpy(copy, str);
strcpy
/* strcpy example */
#include <stdio.h>
#include <string.h>
int main ()
{
char str1[]="Sample string";
char str2[40];
char str3[40];
strcpy (str2,str1);//str1 copies to str2
strcpy (str3,"copy successful");
printf ("str1: %snstr2: %snstr3: %sn",str1,str2,str3);
return 0;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us