[C-prog-lang-l] Testing input issue

Jura Pelc jirik.pelc1998 at gmail.com
Thu Jun 6 10:25:38 CEST 2019


Ok, this not works

čt 6. 6. 2019 v 10:04 odesílatel Jura Pelc <jirik.pelc1998 at gmail.com>
napsal:

> I found the bug and solve it. It looks like the stack was somehow fill
> from the last interation of cycle. A simle condition solve it
>
> if(gets(str) == NULL)
>           LastCommand = 1;
>
> Thans,
>
> čt 6. 6. 2019 v 9:54 odesílatel Jura Pelc <jirik.pelc1998 at gmail.com>
> napsal:
>
>> In basic I have this cycle:
>>
>> while(1)
>> {
>>           char str[MAX_COMMAND_LENGTH + 1];
>>           fgets(str, MAX_COMMAND_LENGTH + 1, stdin);
>> }
>> cmd is: echo '1p' | ./app Small.txt
>> and output is:
>>
>> 49 112 10Lorem ipsum dolor sit amet consectetuer eu Praesent dui libero
>> Donec. Enim diam lobortis risus nec tempus tortor a Curabitur adipiscing
>> Duis.
>>  49 112 10Lorem ipsum dolor sit amet consectetuer eu Praesent dui libero
>> Donec. Enim diam lobortis risus nec tempus tortor a Curabitur adipiscing
>> Duis.
>>  49 112 10Lorem ipsum dolor sit amet consectetuer eu Praesent dui libero
>> Donec. Enim diam lobortis risus nec tempus tortor a Curabitur adipiscing
>> Duis.
>>  49 112 10Lorem ipsum dolor sit amet consectetuer eu Praesent dui libero
>> Donec. Enim diam lobortis risus nec tempus tortor a Curabitur adipiscing
>> Duis.
>>  49 112 10Lorem ipsum dolor sit amet consectetuer eu Praesent dui libero
>> Donec. Enim diam lobortis risus nec tempus tortor a Curabitur adipiscing
>> Duis.
>> ... infinite
>>
>>
>> These numbers are chars in str
>> It looks like the input is cycling or the buffer counter not moving.
>>
>> čt 6. 6. 2019 v 9:26 odesílatel Vladimír Kotal <vlada at devnull.cz> napsal:
>>
>>> In general there should not be much difference modulo buffering however
>>> that should not impact the outcome.
>>>
>>> How exactly do you test for end of input ?
>>>
>>>
>>> V. Kotal
>>>
>>> Dne st 5. 6. 2019 23:13 uživatel Jura Pelc <jirik.pelc1998 at gmail.com>
>>> napsal:
>>>
>>>>
>>>> Hi,
>>>> I finished coding Ed Phase 1. I thing (I hope) I have done everything
>>>> according to task. Today I want to start testing and found one issue.
>>>> The first test ended in infinite loop. I found, then the application
>>>> infinitely reading input a executing it.
>>>> When the same input is used in running application it is fine.
>>>>
>>>> I have these construct to gen input
>>>>                 fgets(str, MAX_COMMAND_LENGTH + 1, stdin);
>>>> And command is:
>>>>                 1p
>>>> I let app to print me chars and in both situations it is 49, 112, 10
>>>> So newline char is here and fgets should stop at new line
>>>>
>>>> So my question is: *What is difference between standard input directly
>>>> from console and send by pipe?*
>>>>
>>>>
>>>> --
>>>>
>>>> S pozdravem Jiří Pelc
>>>> Matematicko-fyzikální fakulta
>>>> Univerzita Karlova
>>>> _______________________________________________
>>>> c-prog-lang-l mailing list
>>>> c-prog-lang-l at mff.cuni.cz
>>>> http://mbox.ms.mff.cuni.cz/listserv/listinfo/c-prog-lang-l
>>>>
>>> _______________________________________________
>>> c-prog-lang-l mailing list
>>> c-prog-lang-l at mff.cuni.cz
>>> http://mbox.ms.mff.cuni.cz/listserv/listinfo/c-prog-lang-l
>>>
>>
>>
>> --
>>
>> S pozdravem Jiří Pelc
>> Matematicko-fyzikální fakulta
>> Univerzita Karlova
>>
>
>
> --
>
> S pozdravem Jiří Pelc
> Matematicko-fyzikální fakulta
> Univerzita Karlova
>


-- 

S pozdravem Jiří Pelc
Matematicko-fyzikální fakulta
Univerzita Karlova
-------------- next part --------------
HTML attachment scrubbed and removed


More information about the c-prog-lang-l mailing list