News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

how to use scanf

Started by vadiu, November 21, 2005, 03:30:21 PM

Previous topic - Next topic

vadiu

Hey guys.
I would like to know if there is a way to use scanf function to read from a file. What should I do? Is there another function as easy to use and as powerful as scanf?

Thanks

Vortex

Hi vadiu,

Here is an example for you :
.386
.model flat,stdcall
option casemap:none

include     \masm32\include\windows.inc
include     \masm32\include\kernel32.inc
include     \masm32\include\msvcrt.inc

includelib  \masm32\lib\kernel32.lib
includelib  \masm32\lib\msvcrt.lib

.data
text1   db "Enter a DWORD value :",0
format1 db "%d",0
format2 db "x = %d",0

.data?
x dd  ?

.code
start:

    invoke  crt_printf,ADDR text1
    invoke  crt_scanf,ADDR format1,ADDR x
    invoke  crt_printf,ADDR format2,x
    invoke  ExitProcess,0

END start

[attachment deleted by admin]