Visual C++ and vsscanf

Posted by Kaya Kupferschmidt • Wednesday, February 1. 2006 • Category: C++
When it comes to its IDE and its compiler, I consider Microsoft Visual C++ 7.1 and up to be a very good product. Especially the C++ language compatibility is at a very high level. But when it comes to its included standard C library, its compatibility even has gone worse with the 8.0 release, and its C99 compliance is also very liited.

This fact can you get into troubles earlier than one might guess. When you want to write your own string classes (and also in some other cases), it is useful to have a method with a variable number of arguments that in turn calls sprintf or sscanf (which both accept a variable number of arguments). Image the following:

class String {
public:
   int sprintf(const char* fmt,...)

private:
   char* _Buffer;
}

int String::sprintf(const char* fmt, ...) {
   va_list arglist;
   va_start(arglist, fmt);
   return sprintf(_Buffer, fmt, arglist);
}

Continue reading "Visual C++ and vsscanf"


A Simple Sidebar