The task is as follows. I need to enter 2 sentences, the second consists of 3 words, and the 2 and 3 words in the second sentence should be swapped. Here is the code itself on pure C (!), Added comments:
#include <stdio.h> #include <string.h> #include <conio.h> int main() { char str1[100] = "\0", str2[100] = "\0", str3[100] = "\0"; puts("Vvedite str1: "); gets(str1); puts("Vvedite str2: "); gets(str2); int i, n = 0, k = 0, h = 0, l = strlen(str2); //n - ΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ ΠΏΠ΅ΡΠ²ΠΎΠ³ΠΎ ΠΏΡΠΎΠ±Π»Π΅Π»Π° //k - ΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Π²ΡΠΎΡΠΎΠ³ΠΎ ΠΏΡΠΎΠ±Π΅Π»Π° //h - ΡΡΠ΅ΡΡΠΈΠΊ ΠΏΡΠΎΠ±Π΅Π»ΠΎΠ² //l - ΠΊΠΎΠ»ΠΈΡΠ΅ΡΡΠ²ΠΎ Π±ΡΠΊΠ°Ρ Π² str2 for (i = 1; i < l; i++) { if (str2[i] == ' ') { h++; if (h == 1) { n = i+1; } if (h == 2) { k = i+1; } } } //ΡΠΈΠΊΠ» ΠΏΠΎΠΈΡΠΊΠ° ΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΈΡ ΠΏΠ΅ΡΠ²ΠΎΠ³ΠΎ ΠΈ Π²ΡΠΎΡΠΎΠ³ΠΎ ΠΏΡΠΎΠ±Π΅Π»Π° printf("\nn = %d, k = %d, h = %d, l = %d", n, k, h, l); int y = k - n; //y - ΠΊΠΎΠ»ΠΈΡΠ΅ΡΡΠ²ΠΎ Π±ΡΠΊΠ² Π²ΠΎ Π²ΡΠΎΡΠΎΠΌ ΡΠ»ΠΎΠ²Π΅ for (i = n + 1; i < k; i++) { strcpy_s(str3, y, str2); } //ΡΠΈΠΊΠ», ΠΊΠΎΠΏΠΈΠΏΠ°ΡΡΠΈΡΡΡΡΠΈΠΉ Π²ΡΠΎΡΠΎΠ΅ ΡΠ»ΠΎΠ²ΠΎ Π² str3, Π² ΠΊΠΎΡΠΎΡΠΎΠΌ Π΅ΡΡΡ ΠΎΡΠΈΠ±ΠΊΠ° Β―\_(γ)_/Β― printf("\n", str3); _getch(); return 0; } I work in a Visual Studio 2015 environment. And it requires writing some operators with underscores and "s" ("_s"). Normal strcpy can not be used, because there is some garbage with security. As I found out, strcpy_s has its own format, that is,
strcpy_s('ΠΊΡΠ΄Π° Π²ΡΡΠ°Π²ΠΈΠΌ', 'ΡΠΊΠΎΠ»ΡΠΊΠΎ Π±Π°ΠΉΡ ΠΊΠΎΠΏΠΈΡΡΠ΅ΠΌ', 'ΠΎΡΠΊΡΠ΄Π° ΠΊΠΎΠΏΠΈΡΡΠ΅ΠΌ'); But my compiler displays an error. 
What needs to be corrected to complete the task (copy the second word -> paste it into str3)?