Recursive function call

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Sep 24 05:13:00 PDT 2014


How about using a loop?

     string getFileName() {
         while(true) {
             string filename = chomp(readln());
             string path = getcwd();
             writeln((path ~ "\\" ~ filename));
             if (exists(path ~ "\\" ~ filename))
		return (path ~ "\\" ~ filename);
             writeln("File do not exists. Please try again");
	}
     }


More information about the Digitalmars-d-learn mailing list