The above example has created a new file with a single char written inside it. How will we know that the file has been created and the data has been stored? The message "saved" at line 7 is just a message, it is not an actual indication of whether the writing has actually taken place. Even if you remove the "fputc()" (line 6) from the above code, the "saved" message will still appear because it has nothing to do with whether writing was successful or not. Then how will we check that the program has run successfully.
You can choose any of the following methods to read the file.1. Open the file using "My computer" : Open my computer and search the file you have just created ("test" in the above example). Double click on the file name to open it. If Windows shows a message that "Windows can't open this file", choose "Select a program from a list of installed programs" and click on OK. From the next window which shows "Open with" select "Notepad" and click on OK. This will open the file in "Notepad".
2. In the "Turbo C" or other IDE - Select "Open" from the file menu. In the "file name" text box type the name of the file(test) and place a dot(.) at the end. For example in the above code the file we are creating a file named "test", so to open it type "test.". This will open the file inside the "C" window. You can see the char you typed there.
3. In the "Turbo C" IDE (software) Click "File--> DOS Shell". You will see a black screen called the DOS Window with some thing like "c:\tc3\bin" written inside it. This is called the DOS prompt. You will also see a cursor blinking there. Type "type test" and press enter, this is the DOS command for printing a file. Your file should get displayed here. To return to the C window type "Exit" and press enter again.
0 comments:
Post a Comment