Question

Locked

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//

inputFile.open("c:\\rainfall.txt");
cout << "Reading data from file" << endl;
inputFile >> study_name; //Problem here - It only displays "Rain"//
cout << study_name << endl;

inputFile.close();

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

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Back to Software Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums