0

Hello,
Thouh i am 60 years old i am still a beginner in c++ and i need some directions from more experienced programmers.

The following code successfully reads file clip1.txt.

I want to replace the quoted file "clip1.txt" with an expression or a variable or a pointer as i have a large number of files to be processed. The files will be processed with a loop.

I tried to use an indexed string array clip1[30] (exemple clip[ 0]= "clip1.txt") but it did not work .

The error code is: No matching function for call to std::basic_ifstream<char, std:; char.......>.

The aim is to avoid rewriting the same piece of code many times.

ifstream file1 ("clip1.txt", ios::in|ios::binary|ios::ate);
if (file1.is_open())
{
size3 = file1.tellg();
memblock1 = new  char [size3];
file1.seekg (0, ios::beg);
file1.read (memblock1, size3); //
file1.close();                                //

I would appreciate a clue about solving this problem.

thanks

monere

Edited by happygeek: fixed formatting

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by monere
0

Post the code which shows the error message, not the near equivalent which does compile.

> I tried to use an indexed string array clip1[30] (exemple clip[ 0]= "clip1.txt") but it did not work .
At a guess. ifstream file1 ( clips[0].c_str(), ios::in|ios::binary|ios::ate);

0

Hello Salem,

Thank you very much for your speedy and exact solution to the problem i raised. It just work great at your fix is going to help me a lot in the development of the prototype application i am tring to set up.

I am going to check the books about the exact meaning of the c_str() that you added to the file name clip[0].

Today i learned and did good progress because of your help.

Regards

Monere

Post the code which shows the error message, not the near equivalent which does compile.

> I tried to use an indexed string array clip1[30] (exemple clip[ 0]= "clip1.txt") but it did not work .
At a guess. ifstream file1 ( clips[0].c_str(), ios::in|ios::binary|ios::ate);

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.