3
I’m having trouble dealing with string
.
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
bool ArqExiste(string Arquivo)
{
ifstream verificacao (Arquivo.c_str());
if(verificacao.is_open())
{
verificacao.close();
return true;
}
else
{
verificacao.close();
return false;
}
}
int main()
{
string file = "C:\\Temp\\aipflib.log";
printf("%b", ArqExiste(file));
}
On the line ifstream verificacao (Arquivo.c_str())
, gave the error:
variable 'Std::ifstream check' has initializer but incomplete type
I use Codeblocks to program.
Not that it’s the cause of the problem, but you have some reason to use the
c_str()
? Try adding:#include <fstream>
– Maniero
Which version of C++ are you using? (C++11 or C++98) because they have right constructors.
– Ricardo
Wouldn’t a second parameter be required for this constructor? because depending on its objective it will be necessary to pass a second parameter http://www.cplusplus.com/reference/fstream/ifstream/ifstream/
– Ricardo
Solved the problem with the solution I gave you?
– Maniero
Yes, you did. Thank you very much, beast.
– Marcelo Nascimento
As for the C++ version, I have no idea. What is the best program for C++. Codeblocks? Visual Studio?
– Marcelo Nascimento
@Marcelonascimento does not have the best program, that is taste, each one has its advantages and disadvantages. Either way these programs you talked about are just the IDE and not the compiler, although each of them comes with specific compilers.
– Maniero