#include <stdio.h>
#include <string.h>
 
void sumFn(char* d, char* s) {
    int sum = 0;
 
    while (*s) {
        *d = *s;
        d++;
        s++;
    }
    *d = '\0'; 
}
 
int main() {
    char* str1 = "first";
    char str2[50] = "teststring";  
    int result=0;
    sumFn(str2, str1);
 
    for (int i = 0; str2[i] != '\0'; i++) {
        result += i;
    }
    printf("%d", result);
    
    return 0;
}

// index: 0 1 2 3 4 5    6 7 8 9 10
// value: f i r s t \0   r i n g \0

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: