flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
revolution 03 Jan 2008, 06:36
twgt: I am not sure what you are saying. Is that a question or are you offering advice?
|
|||
![]() |
|
twgt 03 Jan 2008, 07:24
revolution, it's experience.
![]() Look at real sample. Code: .loop: ;wait for connect .............................................................. cinvoke printf,<"Accept connection?[y/n]: "> mov dword[userinput],0 cinvoke scanf,"%c",userinput cinvoke printf,<13,10> cmp [userinput],'y' jz @accept_connection cinvoke printf,<"Connection not accepted",13,10,"Wait for another connection",13,10> invoke closesocket,[clientsock] ;mov [clientsock],0 jmp .loop Log of work: Quote:
Understand? |
|||
![]() |
|
revolution 03 Jan 2008, 07:44
You might want to think about draining the keyboard buffer before asking the user for input. But it depends on how your program operates as to whether that is a good alternative.
|
|||
![]() |
|
Yardman 03 Jan 2008, 08:01
[ Post removed by author. ]
Last edited by Yardman on 04 Apr 2012, 03:08; edited 1 time in total |
|||
![]() |
|
vid 03 Jan 2008, 09:46
twgt: "scanf("%c", ...)" is NOT waiting for user to type one character. It is reading one character from STDIN. Stdin can be redirected from file, in that case user doesn't type anything.
If stdin is not redirected from file, it reads from console. Any reading from console causes program to stop, and lets user type one line, regardless of how much you are reading from it. After you type one line, desired amount of characters are returned, and rest stay buffered, and are returned in sebsequent reads. For example, in your demo, try to type "abcdyynnyn" and then hit tner. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.