Write a program to read and print a text file on screen



Write a program to read and print a text file on screen..

Answer / ashwek

/// Using C++

#include<iostream>
#include<fstream>
#include<stdio.h>

int main(){

char Data[200];
ifstream File("FILE_NAME"); //Opening a File

while(File){ //Run until End of file
File.getline(Data, 200); //Read data from file & store in Data (string)
cout<<Data; //Print data
}
File.close();

return 0;
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Programming Languages AllOther Interview Questions

Create a class TicTacToe that will enable you to write a complete program to play the game of Tic-Tac-Toe. The class contains as private data a 3- by-3 double array of integers. The constructor should initialize the empty board to all zeros. Allow two human players. Wherever the first player moves, place a 1 in the specified square; place a 2 wherever the second player moves. Each move must be to an empty square. After each move determine whether the game has been won and whether the game is a draw. If you feel ambitious, modify your program so that the computer makes the moves for one of the players automatically. Also, allow the player to specify whether he or she wants to go first or second. If you feel exceptionally ambitious, develop a program that will play three-dimensional Tic-Tac-Toe on a 4-by-4-by-4

2 Answers  


WHAT IS NV RAM ?

3 Answers  


Outline the two important features of a terminating recursion. Any ideas?

0 Answers  


How to know we are in home page of a web application using QTP

0 Answers   HCL,


How to call a C++ function which is compiled with C++ compiler in C code?

0 Answers   Yahoo,


Explain three modes in which files can be accessed from python program

0 Answers   Peerless,


Is there any standard procedure to test the application as a whole? Or How can I test complete application right from the requirement gathering?

0 Answers  


I am looking for selenium RC online Training in chennai. can any one tell me the best institute

0 Answers  


what is oops?

4 Answers   Satyam,


what is client server & server? What r types of Joins? explsin it! which types of indexex in sql server? what is triggers?

0 Answers  


I m Abdullah Ansari compleated MCA from Jamia Hamdard,i have appeared the test of IBM on 2 august at oxford college of engineering Bangalore.waiting for hr round.. This is the first round for IBM.02/08/08 Paper consists of 4 sections 15 questions from matrices(time very less but no negative marking). 25 questions from series completion section (this section is very easy but negative marking) 15 questions from aptitude(little bit tough time limit 15 minute negative marking) 4th section is from computer science (c,c++,operating system,digital electronics ,basic question..) result came at 3 o'clock.i was selected... In interview they asked questions like 1 they asked about final yr project.. 2 what are dynamic and static memory location? 3 linked list and array difference between them. 4 what is function ? what is difference betwen function and inline function? 5 about structure 6 about binary tree, traversal, call by value. 7 storage class and many more basic questions..

0 Answers   IBM,


can we use commit,rollback in triggers and how?

0 Answers   Sierra Atlantica,


Categories