Tuesday, February 24, 2009

program to inter lines in files in read and write the lines for file!

#include"iostream.h"
#include"fstream.h"
#include"string.h"
int main()
{
ofstream fout;
fout.open("gne.txt");
char ch[50];
int len,count=0,sp=0,line=0;

fout<<"guru nanak dev engg. college \n ludhiana \n bracnh \n d2IT ";

fout.close();

ifstream fin;

fin.open("gne.txt");

while(!fin.eof())

{

fin.getline(ch,80);

cout< len=strlen(ch);

for(int i=0;i<=len;i++)

{ if(ch[i]=='  ')

sp++;
else
count++;
}
line++;

cout"number  of  spaces"  sp;

cout"number of  charater" count;

 sp=count=0;

 }

cout<<" \n No.lines= " lines;

fin.close();

return (0);

}

No comments:

Post a Comment