面试题答案
一键面试#include <stdio.h>
#include <string.h>
int calculateTotalLength(char *strArray[], int size) {
int totalLength = 0;
for (int i = 0; i < size; i++) {
totalLength += strlen(strArray[i]);
}
return totalLength;
}
可以使用如下方式调用:
int main() {
char *strings[] = {"hello", "world", "test"};
int size = sizeof(strings) / sizeof(strings[0]);
int result = calculateTotalLength(strings, size);
printf("Total length: %d\n", result);
return 0;
}