Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am new to c++ ... i want to split a string into two equal parts . I am getting the build error
" C2228: left of '.substr' must have class/struct/union"


What I have tried:

void Divide(String^ messageText)
{
int length = sizeof(messageText);
int sublength = length/2;
String ^FirstString;
FirstString = messageText.substr (0,sublength);
}
Posted
Updated 4-Jan-18 23:19pm
Comments
Karthik_Mahalingam 5-Jan-18 2:39am    
Delete other 2 questions and keep 1.
Greek Varak 5-Jan-18 3:21am    
deleted...
Richard MacCutchan 5-Jan-18 4:58am    
It looks like you are mixing managed and non-managed code. I am not sure if the sizeof operator is available in CLI. And if it is that expression will yield the size of a reference rather than its content.

1 solution

The reason of above error is described here: Compiler Error C2228[^]. Follow the link to find out what causes it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900