How to read and display strings in C ?

By fafdsfs ·
so i have a txt file and the first line is "Rain Fall Average"

what code can i use to read the first line and then display it on the console window.

this is what i have so far.

#include <iostream>
#include <fstream>
using namespace std;
int main()

ifstream inputFile;
char study_name[71]; //NOTE - study name must contain up to 70 character//"c:\\rainfall.txt");
cout << "Reading data from file" << endl;
inputFile >> study_name; //Problem here - It only displays "Rain"//
cout << study_name << endl;


//is it possible displaying the title with a char variable or must i use a string //

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Related Discussions

Related Forums