I want to read a text file and save each line in an array. When I used the code below, "echo% i%" prints 0 each time, and only the value of the array [0] is assigned. But in "set n =% i%", the value of n is assigned as the last incremental value of i. Also "@echo! Array [%% i]!" prints as an array [0]! instead of typing a value. Is there any syntax error in the code?
set /A i=0 for /F %%a in (C:\Users\Admin\Documents\url.txt) do ( set /A i+=1 echo %i% set array[%i%]=%%a ) set n=%i% for /L %%i in (0,1,%n%) do @echo !array[%%i]!
source share