2 sentences are given (1e ends with a dot; sentences are separated by a space). It is necessary to change the sentences in places.

It is desirable to do on arrays, without unnecessary C ++ functions.

Look plz, I wrote on VS 2010. I did, but it does not work for me (it produces various kinds of errors, I suppose problems with the compiler):

#include<windows.h> // Π’Ρ‹Π·ΠΎΠ² Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΠΈ для смСны ΠΊΠΎΠ΄ΠΈΡ€ΠΎΠ²ΠΊΠΈ #include<iostream> // Π’Ρ‹Π·ΠΎΠ² Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΠΈ для Π·Π°Π΄Π΅Ρ€ΠΆΠΊΠΈ экрана #include<stdio.h> #define SZ 70 void main (void) { SetConsoleOutputCP(1251); // Π‘ΠΌΠ΅Π½Π° ΠΊΠΎΠ΄ΠΈΡ€ΠΎΠ²ΠΊΠΈ Π½Π° "windows-1251" FILE *In; In = fopen("In.txt", "r"); // Π² Ρ„Π°ΠΉΠ»Π΅ 2 прСдлоТСния char s[SZ]; int end, i; // Π²Π²ΠΎΠ΄ строки ΠΈΠ· Ρ„Π°ΠΉΠ»Π° Π² массив s for(i = 0; i < SZ; i++){ fscanf(In, "%c", s[i]); } fclose(In); // ΠΎΠΏΡ€Π΅Π΄Π΅Π»Π΅Π½ΠΈΠ΅ ΠΊΠΎΠ½Ρ†Π° 1Π³ΠΎ прСдлоТСния for(i = 0; i < SZ; i++){ if (s[i] == '.'){ end = i; break; } } // Π²Ρ‹Π²ΠΎΠ΄ 2Π³ΠΎ прСдлоТСния for(i = end + 2; i < SZ; i++){ printf("%c", s[i]); } printf(" "); // Π²Ρ‹Π²ΠΎΠ΄ 1Π³ΠΎ прСдлоТСния for(i = 0; i <= end; i++){ printf("%c", s[i]); } system("pause"); } 

After starting the program, an error flies:

Unhandled exception in "0x5ba8de8f (msvcr100d.dll)" in "it_lab_6.exe": 0xC0000005: Access violation when writing "0xffffffcc".

indicating the source file input.c:

 #ifndef _UNICODE *(char *)pointer = (char)ch; pointer = (char *)pointer + 1; 

    2 answers 2

    PLAN "A"

    1. Determine the file size. It is possible with the help of fseek.
    2. Select a place under the buffer, where everything is counted.
    3. Use fread and read everything at once.
    4. We go through the array until we meet '.'. All that is behind the point - we copy into a separate array and zero it in the original one.

    PLAN B"

    In the loop, read lines from the file using fgets. This function reads a strictly ONE line. Well, and then there are no problems :-)

    • fread'om into an array or a string variable? If the latter, then how to disassemble the string in the array? - Rasim Bayturin
    • The string is an array of chars. So it makes no difference. You just need to take into account that fread will not add the ending character '\ 0', but will output the data as it is in the file. fgets does the "real" 0-terminated string. Read the help. - gecube
     #define n 70 

    change to sz 70

     for(i = 0;(i<n)&&(s[i]!=' '); i++); end=i; 

    Perhaps it is better to read the string

     fscanf(In, "%s", s); 

    try using getch () instead of pausing from conio.h

    • I will add. Yes, and you need to check not a single space character "", and two - a point-space ".". By description, fscanf(In, "%s", s); , extracts only part of a character sequence to a space, tab, or newline. And this, indeed, would be worth removing (char)" " , replacing it with single quotes :). - Dex
    • Yes, the truth is needed there while (! Eof) and concatenation - Sergey
    • There, by the way, I should not have a space character, but a period (wrong). If we count a string, then how to break it into an array? (with lines as I recall, a similar error also pops up) With a pause, everything is normal in other projects. PS If it's not difficult for anyone, plz check my code on VS. And then, I suppose, my compiler is dead. - Rasim Bayturin
    • Try pausing to replace and define, check if you have enough characters in the file. - Sergey
    • Yes, I tried. All also with an error. There are enough characters. I tried to remove parts of the code - the error is reduced to reading from a file (pointing to input.c char) - what does this mean? - Rasim Bayturin