1. 程式人生 > >printf 輸出字串 需要加上 c_str()

printf 輸出字串 需要加上 c_str()

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
using  namespace std;
int main(){

	string s = "哈哈";

	cout << s << endl;

	printf("a=%s", s.c_str());

	
	std::cout << "Enter two numbers:" << std::endl;
	system("pause");
}