I assume you mean an array of characters and an STL string. The string class takes a char* in one of its constructors. You can also assign a char* to a string object.
Heres what i have for the problem, sorry but im quite a nub at this stuff :/ its killing me though because i had to write a project that was quite long. I was lazy and just put a sentence into a string not thinking anything, but the spaces messed it up somehow.. so.. heh if i could get the input sentence in the program below to be converted into a string i would be home free.
#include <iostream>
using namespace std;
int main()
{
int i = 0, sentencelength = 0;
char letter = 0;
char a[80];
int y = 0;
cout << "Enter a sentance" << endl;
do {
cin.get(letter);
if (letter != '\n')
a = letter;
i++;
sentencelength=i-1;
} while (letter != '\n');
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.