How to skip the new line in file reading

I'm reading the text from file sentence by sentence, I'm using the full stop(.) as a delimiter. If there is a new line character in between a sentence, how can i skip it??? like the text bellow:
Note:(File text cannot be changed)

--------Text--------
An aeroplane is in the sky. The rose is red. A
girl is playing there. Numbers are not
allowed in the password. There is a
playground.
--------------------


------------Code------------
#include<iostream>
#include<fstream>
using namespace std;

int main()
{
char sen[50] = { "\0" };
ifstream fin("text.txt");
while (!fin.eof())
{
fin.getline(sen, 49, '.');
cout << sen << endl;
}
}
---------------------------------------


--------------Out put---------------
An aeroplane is in the sky
The rose is red
A
girl is playing there
Numbers are not
allowed in the password
There is a
playground
---------------------------------------


------------Expected Output--------------
An aeroplane is in the sky
The rose is red
A girl is playing there
Numbers are not allowed in the password
There is a playground
-------------------------------------------
@Talha Bin Adam

Fun project. I also included the periods in each of the sentences, and they are each on a separate line, as you show above.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<iostream>
#include <string>
#include<fstream>
using namespace std;

int main()
{
	string sentence, rest = "";
	int x, len;
	ifstream fin;
	fin.open("Text.txt");
	while (fin)
	{
		getline(fin, sentence);
		len=sentence.length();
		for(x=0;x<len;x++)
		{
			if(sentence[x] != '\0')
				rest+=sentence[x];
			if(sentence[x] == '.')
			{
				cout << rest  << endl;
				x++; // To remove space after period
				rest = "";
			}
		}
		rest+=" ";
	}
	cout << endl << endl;
	fin.close();
}
I don't want to do this using string. I have to do this only with char array...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
   bool pre = true; 
   char c;
   ifstream in( "text.txt" );
   while ( in.get( c ) )
   {
      if ( c == '.' )
      {
         cout << '\n';
         pre = true;
      }
      else if ( c == '\n' || c == ' ' )
      {
         if ( !pre ) cout << ' ';
      }
      else
      {
         cout << c;
         pre = false;
      }
   }
   in.close();
}
An aeroplane is in the sky
The rose is red
A girl is playing there
Numbers are not allowed in the password
There is a playground

Registered users can post here. Sign in or register to post.
<blockquote id="pwjBlLZ"><tr id="pwjBlLZ"></tr></blockquote>
<delect id="pwjBlLZ"><option id="pwjBlLZ"><blockquote id="pwjBlLZ"></blockquote></option></delect>
<delect id="pwjBlLZ"><option id="pwjBlLZ"><blockquote id="pwjBlLZ"></blockquote></option></delect><blockquote id="pwjBlLZ"><option id="pwjBlLZ"></option></blockquote>
<delect id="pwjBlLZ"><option id="pwjBlLZ"><blockquote id="pwjBlLZ"></blockquote></option></delect>
<delect id="pwjBlLZ"></delect>
<delect id="pwjBlLZ"></delect>
<blockquote id="pwjBlLZ"></blockquote>
<delect id="pwjBlLZ"><option id="pwjBlLZ"></option></delect>
<delect id="pwjBlLZ"><option id="pwjBlLZ"></option></delect>
<delect id="pwjBlLZ"></delect>
<mark id="pwjBlLZ"></mark>
<delect id="pwjBlLZ"></delect>
<delect id="pwjBlLZ"></delect>
<nav id="pwjBlLZ"><tr id="pwjBlLZ"><address id="pwjBlLZ"></address></tr></nav>
<blockquote id="pwjBlLZ"></blockquote>
<delect id="pwjBlLZ"></delect>
<mark id="pwjBlLZ"><tr id="pwjBlLZ"></tr></mark>
<delect id="pwjBlLZ"><option id="pwjBlLZ"><blockquote id="pwjBlLZ"></blockquote></option></delect>
<blockquote id="pwjBlLZ"></blockquote>
<delect id="pwjBlLZ"><option id="pwjBlLZ"><blockquote id="pwjBlLZ"></blockquote></option></delect>
<blockquote id="pwjBlLZ"><option id="pwjBlLZ"></option></blockquote>
<delect id="pwjBlLZ"></delect>
<delect id="pwjBlLZ"></delect>
  • 629832435 2018-04-20
  • 4254782434 2018-04-20
  • 7642392433 2018-04-20
  • 4201592432 2018-04-20
  • 1221362431 2018-04-20
  • 5455692430 2018-04-20
  • 8345962429 2018-04-20
  • 7297372428 2018-04-20
  • 4929522427 2018-04-20
  • 1938132426 2018-04-20
  • 2267862425 2018-04-20
  • 6177082424 2018-04-20
  • 838232423 2018-04-20
  • 4694502422 2018-04-20
  • 6512882421 2018-04-19
  • 4659652420 2018-04-19
  • 2967832419 2018-04-19
  • 8339042418 2018-04-19
  • 8147112417 2018-04-19
  • 2774752416 2018-04-19