c++ - 'std::string' has no member named 'get' list[i]=user.get; -
I get this error in my code and I know why it is but now I want to fix it and get it What do I want to achieve? List [i] = user.get; & Lt; & Lt; This line of code is trying to insert a string into four arrays, how can I convert the string, while still being able to keep user.length () and getline, I can see how big my dynamic array Should be
# include & lt; Iostream & gt; # Include & lt; Cstring & gt; using namespace std; Int main () {char * list; String user; Int counter [26]; Int data; The court's & lt; & Lt; "Enter a line of text (all lowercase)" & lt; & Lt; Endl; // CIN & gt; & Gt; the user; Gateline (pin, user); //cin.get(user); The court's & lt; & Lt; User.length () & lt; & Lt; Endl; List = new four [user.length ()]; For (int i = 0; i & lt; user.length (); i ++) {list [i] = user.get; } Cout & lt; & Lt; The list [0] is referred to as & lt; & Lt; Endl; / * Character alphabet [26]; For {int i = 0; i
You can document the string.
The law gives the underlying four array an indicator that you can do in <4> memcpy or strcpy in your own four array. std :: size_t User_length = user.length () + 1; Char * list = new char [user_length]; Strncpy (list, user.c_str (), user_length); ... Delete [] list;
Comments
Post a Comment