Reputation: 13
I want a user to enter a string which will be saved into a variable which will then be Echoed into a text file...
And this is what I've got:
set /p string = Enter string to add to the text file:
echo %string% > saves.txt
echo Added %string% to the text file
but in saves.txt it gives me:
Echo is off.
(I'm sorry if a similar topic has popped up like this but I'm new to programming and I wasn't sure what to get out of it)
Upvotes: 1
Views: 139
Reputation: 70933
set /p string = Enter string to add to the text file:
^ here is the problem
As you are defining a variable with a space in its name, when you echo %string%
, without space, you can not get the content of the variable. Change your code to
set /p "string= Enter string to add to the text file:"
Upvotes: 3