need help in string

i want to do that read the following multiple file from argv like that:

ARGV: C:/>x 4 ../dat doc1.txt doc2.txt doc3.txt
but that not fixed with the name and the path, so i wrote this, but doesn't work....

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

char* path=argv[2];
string getcontent;
for(int i=3; i<argc;i++)
{
   char* file_name_path= path+"/"+argv[i];
   ifstream openfile (file_name_path);
   if (openfile.is_open())
   {
       while (! openfile.eof())
	{
			openfile>>getcontent;//get a string
			opp = new char[getcontent.size() + 1];//allocate space for string
            strcpy(opp, getcontent.c_str());//copy it to the opp char*
		    {header=add(opp, theList);}//use header to call add struct and put char* opp inside
		} 
   }
}
1
2
3
4
5
6
7
8
9
10
11
12
string path=argv[2];
for(int i=3; i<argc;i++)
{
   string file_name_path = path + string("/") + string(argv[i]);
   ifstream openfile(file_name_path.c_str());
   while (openfile)
   {
      string getcontent;
      openfile >> getcontent;//get a string
      header = add(getcontent.c_str(), theList);//use header to call add struct and put char* opp inside
   }
}
Last edited on
Topic archived. No new replies allowed.