+ 1

Someone explain me the -(strncpy.....'\0';) part ?

https://code.sololearn.com/c7gYBQLTCA03/?ref=app

15th Oct 2018, 10:52 AM
Rishab Sharma
Rishab Sharma - avatar
8 Respostas
+ 2
for better understanding of how strncpy check this out : http://www.cplusplus.com/reference/cstring/strncpy/
15th Oct 2018, 5:25 PM
Tanay
Tanay - avatar
+ 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.
15th Oct 2018, 1:57 PM
Tanay
Tanay - avatar
+ 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.
15th Oct 2018, 5:23 PM
Tanay
Tanay - avatar
15th Oct 2018, 4:33 PM
Rishab Sharma
Rishab Sharma - avatar
+ 1
check this nxt strng prob
15th Oct 2018, 4:33 PM
Rishab Sharma
Rishab Sharma - avatar
+ 1
if i jst give input (abcdefghijklpqrs) in string prob 2 thn why i gave jst char from i to s?
15th Oct 2018, 4:35 PM
Rishab Sharma
Rishab Sharma - avatar
+ 1
small number of char get printed .?
15th Oct 2018, 5:36 PM
Rishab Sharma
Rishab Sharma - avatar
+ 1
thnks btw
15th Oct 2018, 5:37 PM
Rishab Sharma
Rishab Sharma - avatar