The program basic is like I have one input file inpt.txt
Shri
600001
600003
Proactive
600004
600006
First I am reading this input file. Now I have other input1.txt file as
600001
I went to college
600002
I don't go to college.
It is tedious program
6000003
Shridhar Ram Rahim
6000004
Very Easy Program
6000005
Life is nice
6000006
Now I want to take input from input.txt use it in input1.txt and produce the output.txt file as foloows:
600001:shri
I went to college
600002:shri
I don't go to college.
It is tedious program
6000003:shri
Shridhar Ram Rahim
6000004:Proactive
Very Easy Program
6000005:Proactive
Life is nice
6000006:Proactive
Please help me as I could able to produce output.txt fie but I could not repeat it for other numbers
Thank you
EditReport
brokenbot (248) Aug 26, 2011 at 1:19pm
Show more code... explain your problem better.
You want to take inpt.txt data and input1.txt data and mash data together and make a new file called output.txt. I don't really understand your system of how you're going to actually know where to put data from inpt.txt and input1.txt to actually logically come up with output.txt
I thought for a second that shri.... ok I get it now. Your numbers are messed up in inpt.txt though.
I don't get how your generating these magical numbers.... Why do you need them?
Do you want to parse a file for a number then match that number in another file resulting in modified output that goes in a completely different file?
Last edited on Aug 26, 2011 at 1:25pmReport
$POINT ID = 600001
I went to college
$POINT ID = 600002
I don't go to college.
It is tedious program
$POINT ID = 6000003
Shridhar Ram Rahim
$POINT ID = 6000004
Very Easy Program
$POINT ID = 6000005
Life is nice
$POINT ID = 6000006
My program is
#include<iostream>
#include<string>
#include<fstream>
#include<iomanip>
#include<sstream>
using namespace std;
struct NVH
{
char name[200];
int points[200];
};
int main()
{
ifstream file;
file.open("input.txt");
ifstream pch;
pch.open("input1.txt");
char input2[300],name2[300];
ofstream pchout;
pchout.open("output.txt");
struct NVH n[200];
long int i,j,k,l,m,p,a,b,c,x,y,z,r,s,d,f;
float e;
long int g,h,t;
int u=900,v=400,w=700;
char nam[300],name[300],input[300],name1[300];
string line;
$POINT ID = 600001Shri
I went to college
$POINT ID = 600002
I don't go to college.
It is tedious program
$POINT ID = 6000003
Shridhar Ram Rahim
$POINT ID = 6000004
Very Easy Program
$POINT ID = 6000005
Life is nice
$POINT ID = 6000006
BUT I want output.txt as
$POINT ID = 600001Shri
I went to college
$POINT ID = 600002Shri
I don't go to college.
It is tedious program
$POINT ID = 6000003Shri
Shridhar Ram Rahim
$POINT ID = 6000004Proactive
Very Easy Program
$POINT ID = 6000005Proactive
Life is nice
$POINT ID = 6000006Proactive
Please help me as I almost done the correct program but I think Only problem as you stated I could not repeat the loop in file.
inpt.txt is a user defined names and range of numbers which the user can change as per his requirement. The input1.txt is a file which contains $POINT ID = 600001 and so on. But it does not contain names behind it as $POINT ID = 600001shri.
So I tried to take user defined input from inpt.txt , using it in input1.txt and taking this changes in output.txt...
I am almost done this with my program for $POINT ID = 600001Shri but I COULD NOT REPEAT IT FOR THE REST OF input1.txt. Simply I think I could not repeat it for other points.(Looping Problem).
I thought I can create the file with cout<<search and I am getting correct output as
$POINT ID = 600001Shri
$POINT ID = 600002Shri
$POINT ID = 600003Shri
$POINT ID = 600004Proactive
$POINT ID = 600005Proactive
$POINT ID = 600006Proactive
But when I am trying to use it in File Management section by find and replace things I think It is not repeating loop for other points 6000002, 6000003 and so on.
So there is problem with file management section.
I used pch.clear() and pch.(0,ios::beg) so that I think the pointer will automatically reset to initial position of input1.txt but I am not getting any change in output.