Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,870 questions

51,793 answers

573 users

How to implement text copy function in C

1 Answer

0 votes
#include <stdio.h>
#include <string.h>
 
void copytext(char text1[], char text2[]) {
    int size = strlen(text2) + 1;
 
    for (char *p = text2; p < text2 + size; p++) {
        text1[p - text2] = *p;
    }
}
 
int main() {
    char text1[30];
    char text2[] = "C Programming";
 
    copytext(text1, text2);
     
    puts(text1);
    puts(text2);
    
    return 0;
}
 
 
 
/*
run:
 
C Programming
C Programming
 
*/

 



answered Dec 26, 2020 by avibootz
edited Dec 26, 2020 by avibootz

Related questions

1 answer 128 views
128 views asked Dec 26, 2020 by avibootz
3 answers 223 views
223 views asked Sep 29, 2015 by avibootz
1 answer 197 views
2 answers 240 views
...