strcpy vs strncpy? Pros / cons??
Code:
pinput = fgets(input, 30, stdin);
strncpy(my_struct.firstName,pinput,30);
fgets(input["I understand"],30["I understand this"], stdin["I don't understand why it needs to be here or what else may or may not take its place"])
strncpy(my_struct.firstname[I understand],pinput[understand],30[makes sense to me])
however
Code:
pinput = fgets(input, buff, stdin);
strncpy((*cl+pclientCounter), pinput, strlen(pinput) - 1)
In this piece of code i am getting confused because of strlen(pinput) -1 ? and why does it require a counter for the struct pointer...
I know you guys don't see the whole code My question isn't about specifically why in this particular code but more so in a general sense. Perhaps if someone could provide a few better examples of how to use these functions properly?
I would be extremely grateful if someone took the time to break these few things down for me. Thanks ahead of time.