The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: t3dbundy on December 03, 2006, 08:03:32 AM

Title: how to use c standard i/o in masm?
Post by: t3dbundy on December 03, 2006, 08:03:32 AM
like this:
invoke printf,....?

but it has assembly error:
Quoteundefined symbol : printf
Title: Re: how to use c standard i/o in masm?
Post by: hutch-- on December 03, 2006, 08:09:48 AM
Ted,

Give the MSVCRT library a try, there are both includes and a library for it but not that the formatting for printf will not work without a C compiler as it is not part of the library routine.
Title: Re: how to use c standard i/o in masm?
Post by: Vortex on December 03, 2006, 08:40:47 AM
t3dbundy,

You should convert C formattings like the following :

char format1[]="%s\n";

to

format1 db '%s',13,10,0
Title: Re: how to use c standard i/o in masm?
Post by: t3dbundy on December 05, 2006, 04:18:41 AM
use like this?

.386
.model flat,stdcall
option casemap :none

include windows.inc
include msvcrt.inc
include kernel32.inc
includelib kernel32.lib
includelib msvcrt.lib

.data
format db '%d',0

.code
start:
invoke crt_printf,addr format,67
invoke ExitProcess,NULL
end start

but,it print nothing in console.
Title: Re: how to use c standard i/o in masm?
Post by: Vortex on December 05, 2006, 06:01:02 AM
Did you specify the subsystem as console?

link /SUBSYSTEM:CONSOLE srcfile.obj
Title: Re: how to use c standard i/o in masm?
Post by: t3dbundy on December 05, 2006, 11:56:33 AM
Quote from: Vortex on December 05, 2006, 06:01:02 AM
Did you specify the subsystem as console?

link /SUBSYSTEM:CONSOLE srcfile.obj
I use ide,only hit the "Build All",let me try it,thx!
Title: Re: how to use c standard i/o in masm?
Post by: Vortex on December 05, 2006, 12:32:52 PM
In your IDE, you need to use something like as Build console application