Okay here is the psuedocode of what I want to do
void openFile(int inputNumber)
{
char* = "//folder//" + inputNumber + ".txt"
}
unfortunately that is not how you append to the end of a char*.
Any suggestions of doing this?
Okay here is the psuedocode of what I want to do
void openFile(int inputNumber)
{
char* = "//folder//" + inputNumber + ".txt"
}
unfortunately that is not how you append to the end of a char*.
Any suggestions of doing this?
strcat()
I am guessing that you are trying to construct a filename. One way:
Now you can use filename.c_str() with say, the constructor of std::ifstream.Code:std::stringstream ss; ss << "//folder//" << inputNumber << ".txt"; std::string filename = ss.str();
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Okay I am about to go try that, but what exactly is stringstream, it looks like cout all over, but copied into a string.
That's the general idea. You should #include <sstream> and <string>, of course.Originally Posted by thegr8n8
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
splendid also how did you get a signature?
For that you'd need a sufficiently large buffer and something like "sprintf" to copy the values to text. Of course, the standard C++ approach is to use an std::stringstream (which works just like the 'cout' object (ie: file streams)). It's "str" member function returns an std::string, whereby you can use either the "data" or "c_str" function to retrieve the const char* that you need to open the file (kind of convoluted, yes!).
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
You may need to hang around for awhile and post before the option becomes available to youOriginally Posted by thegr8n8
Use c_str(), not data(), as the latter does not guarantee a null terminator.Originally Posted by Sebastiani
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
bad conversion from const char* to char*.....
That error message is meaningless in the absence of corresponding code. I can assure you that my example is correct, and that your compiler and I agree that your code is wrongOriginally Posted by thegr8n8
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
lol well sorry this was an error message for a diffrent thing I was doing:
string playerName = "Nathan";
char* = playerName.c_str();
that is where the error message appears at
Why do you want to do that when you already have a string object? Furthermore, you are missing a variable name and c_str() returns a const char* which cannot be assigned to a char*.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
ah I see now, so how would one go from string to regular char* then?
There are a few ways... but why do you want to do this?Originally Posted by thegr8n8
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)