Hi I am trying to call a 3rd party method which relies on const char* I want to pass an arbitrary value.
The (broken) code below should show what I'm trying to do.
#include <iostream>
#define MAX 1000
// 3rd party stuff
void ConstPtrMethod(const char* s) {
std::cout << s << std::endl;
}
// My stuff:
int main() {
const char* ConstBuffer;
for (int i = 0; i < 10; i++) {
char* buf;
buf = ConstBuffer;
sprintf(buf, "%d", i);
ConstPtrMethod(ConstBuffer);
}
}
I'm a cpp noob btw. What I want to know is why the line buf = Constbuffer does not work as well as a way around this if possible.
Thanks in advance.