1 Copies at most n1 ch aracters of string in into the 2 buff
Solution
#include <stdio.h>
int copyStringN(char *in, char *out, int n){
int i=0;
if(n < 0){
return -1;
}
for(i=0; i<n; i++){
out[i]=in[i];
}
return 0;
}
int main()
{
char in[7] =\"testing\";
char out[7];
copyStringN(in, out, 7);
printf(\"Output string value is %s\ \", out);
return 0;
}
Output:
sh-4.2$ gcc -o main *.c
sh-4.2$ main
Output string value is testing
1
