How do I save a string? Say I type in "sfrider0." How do I store that then retrieve it later? I've been messing around with it for a while and the most I can get it to do is tell me how many characters are in it. Any help?

Recommended Answers

All 4 Replies

; you mean storing it even after program close?
; then : In Registry (RegOpenKeyEx, RegQueryValueEx, RegSetValueEx ...) , In a File ( CreateFile, WriteFile, ReadFile ...), In .ini File ( you can easily do that by special API funcs (e.g: GetPrivateProfileString, WritePrivateProfileString ...))

No, just store during the program. I'm trying to input two strings, then put them in alphabetical order. I understand how to compare and order two strings that are hard coded.

; you have to allocate enough memory for the string in the ".data?" ; section:
.data?
szBuff db 256 dup(?)
; then when you call StdIn it will write user input into szBuff

.386
	.model flat,stdcall
	option casemap:none
	include \masm32\include\windows.inc
	include \masm32\include\user32.inc
	include \masm32\include\kernel32.inc
	include \masm32\include\masm32.inc
	includelib \masm32\lib\user32.lib
	includelib \masm32\lib\kernel32.lib
	includelib \masm32\lib\masm32.lib

.data?
	szBuff				db  256 dup(?)
.data
	
.code
start:
call AllocConsole
push sizeof szBuff
push offset szBuff
call StdIn
push offset szBuff
call StdOut
push NULL
call ExitProcess
end start

Got it working! thanks

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.