Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

unix C++ to be modified in visual C++

rocky811rocky811 Member Posts: 12
I have a program in CPP writen in Unix ...I am trying same code to work in some compiler in windows... like i have Visual C++ but i cant use same code its giving me errors can someone help me in modifying this as i am new to visual CPP environment: This is program to modify 2 lines of a file using 2 lines each from 2 others files row by row until all rows are covered and same number as rows of both files.. the modifies files r created with name like... program1.txt program2.txt ...so on ... !!
#include
#include
#include
#include
#include
#include
#include
using namespace std;
ifstream infile1;
ifstream infile2,infile3;
ofstream outfile;
char *line,*line1,*line2,*line3,*line4;
char *str,*num;
int par=0,i=0;
int main(char argc, char * argv[])
{

infile1.open(argv[1]);
infile2.open(argv[2]);
infile3.open(argv[3]);
std::ostringstream sin;
line=new char[100];
line1=new char[100];
line2=new char[100];
line3=new char[100];
line4=new char[100];
str=new char[30];
num=new char [30];
cout<<"enter"<<endl;
while(!infile2.eof())
{
i++;
sin.str("");
infile1.clear();
infile1.seekg(0,ios::beg);
sin << i;


std::string val(sin.str());
cout<<"i: " <<val<<endl;
std::string val1;
//std:: string val2;
val1 = "Program"+val+".txt";
//val2 = "Program"val1+;
outfile.open(val1.c_str());
while(!infile1.eof())
{
infile1.getline(line,100,'
');
cout<<"line: "<<line<<endl;
strcpy(line2,line);
str=strtok(line," ");

while((str=strtok(NULL," "))!=NULL)
{
cout<<"str:"<<str<<endl;
if(strcmp(str,"ths")==0)
{
outfile<<line2<<"
";
infile1.getline(line,100,'
');
infile2.getline(line1,100,'
');
infile1.getline(line,100,'
');
infile3.getline(line4,100,'
');
outfile<<line1<<"
";outfile<<line4<<"
";par=1;
cout<<"done :"<<i<<endl;
}
}
if(par==0)
outfile<<line2<<"
";
par=0;
}
cout<<"line1: "<<line1<<endl;
outfile.close();
}
infile1.close();
infile2.close();
}

Comments

Sign In or Register to comment.