flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
AsmGuru62 23 Jan 2014, 16:29
Where is 'fopen()'?
Code: .save_to_file: ;use fopen() here ... cinvoke fprintf, filename, text ;?? ;use fclose() here ... |
|||
![]() |
|
lukasz3t 23 Jan 2014, 18:08
program is not responding
Code: format PE CONSOLE entry main include 'd:\fasm\include\win32a.inc' section '.data' data readable writeable filename db 'test.txt', 0 type db 'w', 0 text db ? text_size = $ - text section '.code' code readable writeable executable proc main cinvoke scanf mov [text], al cinvoke printf, text .save_to_file: cinvoke fopen, filename, type cinvoke fprintf, filename, text ;?? cinvoke fclose, filename cinvoke getch xor eax, eax .end: ret endp section '.idata' import data readable writeable library msvcrt, 'msvcrt.dll' import msvcrt,\ fopen, 'fopen',\ fclose, 'fclose',\ fgetc, 'fgetc',\ printf, 'printf',\ getch, '_getch',\ scanf, 'scanf_s',\ fprintf, 'fprintf' |
|||
![]() |
|
baldr 23 Jan 2014, 18:35
lukasz3t,
How do you think, what's the prototype of scanf()? |
|||
![]() |
|
AsmGuru62 23 Jan 2014, 20:08
lukasz3t,
Please take a look at every function's parameters. You have used 'filename' in a few places in a wrong way. This is a good point to begin: http://www.cplusplus.com/reference/cstdio/ Also, to read a string -- you need a buffer to read it into. I see you have this: Code: text db ? This is a 1 byte buffer -- you need more room for a string, like: Code: text rb 80 ; 80 bytes of room scanf() is also not used properly, as already mentioned. Take a look at its parameters. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.