I'm pretty sure "%s" is expecting a C style string, not an STL string object, which is what a is declared to be. Use cout instead of printf() or use a.c_str() instead of a.
Mixing C and C++ I/O methods like printf() and cin in the same program isn't recommended.
And, last, but not least, main() should have return type int, not void, even if your compiler allows you to use void in this setting.
Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396
Again, "%s" indicates a C style string. If a is an STL string object then you can use the c_str() method to use a as a C style string.
Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396