printf("It is currently %s's turn.\n", current->name);
我想知道为什么这会在%s之后打印出额外的换行符。我知道C中的字符串总是以\ 0结尾。如何在没有它的情况下打印它?
答案 0 :(得分:7)
您的变量<DesiredConfigurationDigest xmlns="http://schemas.microsoft.com/SystemsCenterConfigurationManager/2009/07/10/DesiredConfiguration">
<SoftwareUpdateBundle AuthoringScopeId="Site_28E438B4-CB2F-43A2-AD6B-5A993F805BCB" LogicalName="SUM_4ca07bc3-8c95-4644-be17-040a3964a02a" Version="201">
<Annotation xmlns="http://schemas.microsoft.com/SystemsCenterConfigurationManager/2009/06/14/Rules">
<DisplayName Text="Security Update for Microsoft OneNote 2010 (KB3114885) 32-Bit Edition" />
<Description Text="A security vulnerability exists in Microsoft OneNote 2010 32-Bit Edition that could allow arbitrary code to run when a maliciously modified file is opened. This update resolves that vulnerability." />
</Annotation>
...
中有换行符,因此您需要删除该换行符。
current->name
这段代码将帮助您摆脱不必要的换行符。把它放在current->name[strcspn(current->name, "\n")] = '\0';
之前。