strdup(): Confused about warnings ('implicit declaration', 'makes pointer…without a cast', memory leak)
问题 When I compile the short piece of code below (in which we define a string and then use strdup to make a copy), I get 3 warnings: 2 compiler warnings from GCC and 1 run-time warning/error from valgrind. I suspect the memory leak error (reported by valgrind) is also related to my use of strdup, which is why I'm including the relevant output below. What am I doing wrong? (I'm working my way through a C book and this is how strdup is used by the author.) The code: #include <stdio.h> #include