Using gets (0)
- Posted by Bob Hancock <bob at SPEED.NET> Dec 17, 1997
- 696 views
Hi: I'm trying to prompt the user for an output filename, into which I will write data. The following code segment will work IF I declare the output file in the source code (the "commented - out" line below). But, if I try to type it in (when prompted) I get the failure to open output file message. I've tried entering the pathname [d:\aa\dataout.txt] with single, and double- backslashes (" \ ", and " \\ "). Both give Error message. I've also tried stripping-off the "\n" -- no difference. Anyone can show me what simple thing I'm missing? Thanks. -- Bob Hancock , [bob at speed.net] = = = = = = = = = = = = = = = = = = = = = include get.e sequence filein, fileout filein = "d:\\aa\\datain.txt" -- fileout = "d:\\aa\\dataout.txt" << ... this will work... >> integer fn, fo puts(1,"What is Name of Output File ?\n") fileout = gets(0) printf(1, "\n\n The OUTPUT is ... %s \n",{fileout}) -- for troubleshooting fo = open(fileout, "w") if fo = -1 then puts(2, "\nCouldnt Open Output File\n") <<-- Failure appears Here! end if = = = = = = = = = = = = = = = = = = = -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Bob Hancock ... ======>bob at speed.net<======== Irvine, CA