How to copy character from string to char data type in C++

1 Answer

0 votes
#include <iostream>
#include <string>

using std::cout;
using std::endl;
using std::string;

int main()
{
	string s = "c c++ java php";

	char ch = s[3];
	cout << ch << endl;
	
	ch = s.at(6);
	cout << ch << endl;

	return 0;
}


/*
run:

+
j

*/

 



answered May 29, 2018 by avibootz

Related questions

1 answer 220 views
1 answer 203 views
1 answer 182 views
1 answer 215 views
1 answer 226 views
...