I am trying to call an interface function and print out the resulting values. The function prototype contains pointers to character string as arguments. When I print out the resulting values I receive some strange symbols. Is my below approach correct?
int interfacecall(char *a, char *b ...);
char * a= "Testdata";
char b [4098];
result= interfacecall(a,b);
//different value is returned in b via function implementation in a third party dll.
printf(b);
Your printf is not that safe. It should be :
In C++, you can also use
std::coutas:Make sure that
bis a null-terminated c-string, otherwise it wil print garbage and may crash your program. Null-terminated string means it must end with\0. Something like this: