【发布时间】:2015-04-11 08:39:28
【问题描述】:
所以当我尝试打印出两个字符串时,第一个字符串不会打印出来。它 显示为空格。例如
#include <stdio.h>
#include <string.h>
int main() {
char noun[10];
char temp[10]; // Stores temporary word entered by user
printf("Please enter word: ");
scanf("%s", noun);
temp[10] = noun[10];
pluralize(noun); // Function adds 's' to scanned word
printf("The word changes from %s to %s", temp, noun);
return 0;
}
所以如果我输入“cat”,输出结果如下:
The word changes from to cats
我需要出现原始单词,而不是空格:
The word changes from cat to cats
【问题讨论】:
-
strcpy()看起来在这里可能会有所帮助。 -
请分享
pluralize的定义。 -
temp[10] = noun[10];一行中有两个越界数组访问。
标签: c string char printf scanf