Re: Scanf function changes value of in-loop variable

2014-04-16 Thread Capture_A_Lag
Thanks everyone for figuring everything out!

Re: Scanf function changes value of in-loop variable

2014-04-16 Thread FreeSlave
It also throws if you input initial or trailing spaces and there are no spaces at the start or end of format string (scanf skips these spaces)

Re: Scanf function changes value of in-loop variable

2014-04-16 Thread FreeSlave
On Wednesday, 16 April 2014 at 18:46:18 UTC, Ali Çehreli wrote: On 04/16/2014 11:36 AM, FreeSlave wrote: Note that readf is not equivalent to scanf since readf does not skip spaces and newline character. Input must completely match format. Just like in scanf, a single space character is suffi

Re: Scanf function changes value of in-loop variable

2014-04-16 Thread Ali Çehreli
On 04/16/2014 11:36 AM, FreeSlave wrote: Note that readf is not equivalent to scanf since readf does not skip spaces and newline character. Input must completely match format. Just like in scanf, a single space character is sufficient to consume zero or more whitespace characters. Ali

Re: Scanf function changes value of in-loop variable

2014-04-16 Thread FreeSlave
Note that readf is not equivalent to scanf since readf does not skip spaces and newline character. Input must completely match format.

Re: Scanf function changes value of in-loop variable

2014-04-16 Thread Justin Whear
On Wed, 16 Apr 2014 18:17:37 +, Capture_A_Lag wrote: > Thank you everybody!!! > I thought %d is ok for all integral types. This is true when using the D format functions (e.g. readf) which are able to inspect the types of the variables being assigned, but scanf is a C function and not types

Re: Scanf function changes value of in-loop variable

2014-04-16 Thread Capture_A_Lag
Thank you everybody!!! I thought %d is ok for all integral types.

Re: Scanf function changes value of in-loop variable

2014-04-16 Thread FreeSlave
On Wednesday, 16 April 2014 at 17:47:05 UTC, Capture_A_Lag wrote: Hi all! I have this code: -- ubyte N, M, K; ubyte[][max][max] Matrix; scanf("%d %d %d", &N, &M, &K); ubyte tmp; for(ubyte n = 1; n <= N; n++) f

Re: Scanf function changes value of in-loop variable

2014-04-16 Thread Dicebot
On Wednesday, 16 April 2014 at 17:47:05 UTC, Capture_A_Lag wrote: Hi all! I have this code: -- ubyte N, M, K; ubyte[][max][max] Matrix; scanf("%d %d %d", &N, &M, &K); ubyte tmp; for(ubyte n = 1; n <= N; n++) f

Re: Scanf function changes value of in-loop variable

2014-04-16 Thread Ali Çehreli
On 04/16/2014 10:47 AM, Capture_A_Lag wrote: > ubyte tmp; > scanf("%d", &tmp); > // After this scanf n becomes 0 for no reason %d is for int. Ali P.S. A friendly request: It makes it much easier for the rest of the group if posts contained compilable, minimal but co

Re: Scanf function changes value of in-loop variable

2014-04-16 Thread Justin Whear
On Wed, 16 Apr 2014 17:47:03 +, Capture_A_Lag wrote: > Hi all! > I have this code: > > -- > ubyte N, M, K; > ubyte[][max][max] Matrix; > > scanf("%d %d %d", &N, &M, &K); > > ubyte tmp; > > for(ubyte n = 1; n <= N;

Re: Scanf function changes value of in-loop variable

2014-04-16 Thread bearophile
Capture_A_Lag: After scanf in loop variable n becomes 0. Is this a bug? Please help me! Have you tried to use a tmp of type int to avoid stomping? Bye, bearophile