0

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

Edited by tomtetlaw: n/a

2
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by tomtetlaw
0

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

choice:  db "                                    "
0

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
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.