foreach: How start a foreach count with specific number?

Marcone marcone at email.com
Wed Jun 2 15:49:36 UTC 2021


Example:

// --args "C:\Users\Usuario\Downloads\dist\Programa.exe"

import modulo;

void main(string[] args){
	if (args.length >= 2)
	{
		string exePrincipal = args[1];
		chdir(exePrincipal.dirName);
		
		foreach(n, i; glob("*")){
			print("{} DATA {}".format(n, i));
		}
	}
}

This print:

0 DATA icone.ico
1 DATA libgcc_s_dw2-1.dll
2 DATA libstdc++-6.dll
3 DATA libwinpthread-1.dll
4 DATA platforms
5 DATA Programa.d
6 DATA Programa.exe
7 DATA Programa.obj
8 DATA Programa.rc
9 DATA Programa.res
10 DATA Qt5Core.dll
11 DATA Qt5Gui.dll
12 DATA Qt5Widgets.dll
13 DATA qte5.d
14 DATA QtE5Widgets32.dll


But I don't want it starts with 0, but other number. How can I do 
it?


More information about the Digitalmars-d-learn mailing list