In one of our classes we were taught that when a function receives as a parameter a vector, it is actually receiving the memory position in which it is allocated, so it is not necessary to return any value since what will be executed within the procedure will automatically be changing in the vector / string itself. But some functions are starting with a *
and returning a vector. Ex:
int strlen(char *s){
int i = 0;
while(s[i]!='char *strcpy(char *dest, char *orig){
int i;
for(i=0; orig[i]!='int strlen(char *s){
int i = 0;
while(s[i]!='char *strcpy(char *dest, char *orig){
int i;
for(i=0; orig[i]!='%pre%'; i++){
dest[i] = orig[i];
}
dest[i] = '%pre%';
return dest;
}
'){
i++;
}
return i;
}
'; i++){
dest[i] = orig[i];
}
dest[i] = '%pre%';
return dest;
}
'){
i++;
}
return i;
}
Example of a default function that returns the number of elements in string .
%pre%Example of a function that is returning a string / vector.
What is the reason some functions start with *
and consequently return a vector?