Problem z obsługą tekstu

0
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <conio.h>


using namespace std;

int main()
{
  [...]
	
		printf( "Polecenie: " );
		char polecenie[100];
		fflush(stdout);
		fgets( polecenie, 100, stdin );

		if (strstr( polecenie, "ustaw") == polecenie) {

                int y = polecenie[6];
                int x = polecenie[7];
                int nowa_wartosc = polecenie[9];
                cout<<"Nie mozna ustawic takiej wartosci ("<<polecenie<<")";
    return 0;
}

Wyjście

Polecenie: ustaw A5 5
Nie mozna ustawic takiej wartosci (ustaw A5 5
).

Czy ktoś może wytłumaczyć mi dlaczego drugi nawas ląduje w nowym wierszu?

1

http://en.cppreference.com/w/cpp/io/c/fgets

Parsing stops if end-of-file occurs or a newline character is found, in which case str will contain that newline character.

1 użytkowników online, w tym zalogowanych: 0, gości: 1