+ 1
Someone explain me the -(strncpy.....'\0';) part ?
8 Réponses
+ 2
for better understanding of how strncpy check this out : http://www.cplusplus.com/reference/cstring/strncpy/
+ 2
when you enter string whose length is greater than or equal to 7 characters it will copy 6th and 7th character to the string d at d[0] and d[1] repectively and at d[2] we are assigning NULL character which indicates the end of the string so when you print d it will only print upto 2 characters.
+ 2
If the end of the source string (which is signaled by a null-character) is found before num(here 15) characters have been copied, destination is padded with zeros until a total of num characters have been written to it.
so when you print destination string it will print only till null encoutered.
+ 1
check this nxt strng prob
+ 1
if i jst give input (abcdefghijklpqrs) in string prob 2 thn why i gave jst char from i to s?
+ 1
small number of char get printed .?
+ 1
thnks btw