Hi,
I have two issues that I am hoping to get assistance with.
To begin with, the code snippee below is designed to read a line from a file, then place a subset of the line in another array.
This works correctly when I place a number in arg 2 of strncpy (i.e. rec+10), but when I use the variable as shown (i.e. rec+namePosition) I receive the following error when compiling, "warning: passing argument 2 of ‘strncpy’ makes pointer from integer without a cast"
In addition, I am printing the name array for debugging purposes, and i am getting two of every line (i.e. when it works by adding rec+10 instead of the variable name)
The variable namePosition is an argument that is passed in via the commad line, and is set as follows
int namePosition = atoi(argv[3]); /* get the name position */
while(fgets(rec, recLength, file)!=NULL) {
/* Add the null char to the end of the name array */
name[nameLength - 1] = '\0';
/* place the name from the file in the name array */
strncpy(name, rec+namePosition, nameLength -1);
printf("%s \n", rec);
}