Top "Strcpy" questions

The C standard library function, "strcpy()," is used to copy non-overlapping, null-terminated strings.

Proper way to empty a C-String

I've been working on a project in C that requires me to mess around with strings a lot. Normally, I …

c string strcpy
How to correctly assign a new string value?

I'm trying to understand how to solve this trivial problem in C, in the cleanest/safest way. Here's my example: #…

c string struct strcpy
Why should you use strncpy instead of strcpy?

Edit: I've added the source for the example. I came across this example: char source[MAX] = "123456789"; char source1[MAX] = "123456789"; char …

c buffer-overflow strcpy c89 strncpy
Does C have a string type?

I have recently started programming in C, coming from Java and Python. Now, in my book I have noticed that …

c string char printf strcpy
error: function returns address of local variable

I'm beginner with C and I am learning on my own. I am creating the following function: char *foo(int …

c return strcpy strcat
strcpy vs. memcpy

What is the difference between memcpy() and strcpy()? I tried to find it with the help of a program but …

c memcpy strcpy
strcpy vs strdup

I read that strcpy is for copying a string, and strdup returns a pointer to a new string to duplicate …

c strcpy strdup
segmentation fault with strcpy

I am wondering why am I getting segmentation fault in the below code. int main(void) { char str[100]="My name …

c segmentation-fault strcpy
Converting char* to unsigned char*

How do I copy a char* to a unsigned char* correctly in C. Following is my code int main(int …

c char sha1 unsigned strcpy
Using strcpy with a string array in C

I have a character array defined as follows: char *c[20]; I'm trying to do: strcpy(c[k], "undefined); but it's …

c arrays char strcpy