Skip to main content

Thread: Replacing string in C


hi. let's have strings in c:
code:
char *c1 = "hello"; char *c2 = "bye";
c2 @ large c1. if want replace "hello" in c1 contents of c2, c1 "bye"?. there way this?

if understand want, recommend using strncpy.

code:
c1 = strncpy(c1, c2, buf_size);
i think it. buf_size macro maximum size of string, maybe 256 or less ridiculous maybe 64. or put strlen in there.

code:
c1 = strncpy(c1, c2, strlen(c2));
i think meant.


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk Replacing string in C


Ubuntu

Comments

Popular posts from this blog

Flip address is out of range arduino uno r3

Arduino Uno not uploading

Indesign and MathType fonts