Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

copy a number of characters to another string in c without standard library

// CPP program to copy one string to other
// without using in-built function
  
#include <stdio.h>
int main()
{
    // s1 is the source( input) string and s2 is the destination string
    char s1[] = "GeeksforGeeks", s2[100], i;
  
    // Print the string s1
    printf("string s1 : %s
", s1);
  
    // Execute loop till null found
    for (i = 0; s1[i] != ''; ++i) {
        // copying the characters by
        // character to str2 from str1
        s2[i] = s1[i];
    }
  
    s2[i] = '';
  
    // printing the destination string
    printf("String s2 : %s", s2);
  
    return 0;
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #copy #number #characters #string #standard #library
ADD COMMENT
Topic
Name
8+9 =