int _tmain(int argc, _TCHAR* argv[])
{
char string1[20], append_string[40];
char *string2 = "APPENDED"; /* string to be appended */
/* prompt for string 1 */
printf("Enter string1: ");
scanf_s("%s", &string1);
while (!strcmp(string1, "done") == 0)
{
printf("Before append. \nString1: %s \nString2: %s\n\n", string1, string2);
mystrappend(string1, string2, append_string);
printf("After append. \nString1: %s \nString2: %s \nAppended string: %s\n\n", string1, string2, append_string);
// prompt for string 1
printf("Enter string1: ");
scanf_s("%s", &string1);
}
return 0;
}
왜 입력하지 않고 String1
을 저장하지 않습니까?
나는 stdio.h
, conio.h
, string.h
및 stdafx.h
의 헤더 파일을 가지고 있습니다. the documentation of scanf_s
인용왜 내 문자열에 아무 것도 저장하지 않습니까?
어떻게'mystrappend'이 구현처럼
을 찾아야한다? –
Atm, 아직 작업 중이지만, 뭔가를 입력 할 때 비어있는 String1이 내부에 뭔가 있더라도? 내 말은 –
입니다. 나는 당신의'scanf_s' 호출이'scanf_s ("% s", string1)'배열의 주소를 가져서는 안된다고 생각합니다. –