I am trying to make a program that prompts the user for input then outputs it to them(back to the good old days :D). It all works, except it doesn't output what the user inputs, it outputs a bunch of crazy numbers, can someone help me?

Btw I am using NASM.

Test Run:

Please enter something(max 255 chars): tom
You entered: 7
[section .data]
	choice:  db ""
	fmt1:    db "%s",10,0
	output:  db "Please enter something(max 255 chars): ",0
	output2: db "You entered: %s",0
[section .text]
	global _main 
	extern _printf, _scanf 
_main:
	push output
	call _printf
	add esp, 4
	
	push choice
	push fmt1
	call _scanf
	add esp, 8
	
	push dword[choice]
	push output2
	call _printf
	add esp, 8
	
	mov eax, 0
	ret

choice is defined as "" maybe you should try defining it as an array of characters. Something like

choice:  db "                                    "

What that did is after I inputed "tom" into it, it waited for me to input another peice of text and then still said that I had entered 7, this is what it looks like:

Please enter something: tom

h
You entered: 7

I think it's because it's not converting the characters from their ascii codes to their actual value, is this right?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.