Error parsing string in C " left operand must be l-value" -


I am facing the need to drag information into a string of "blah.bleh.bloh" format in ANSI. C. Generally I use stroke () to complete it, but since I am getting this string through string, and strtok thread is not secure, I can not use this option.

I've written a function that parse the string manually: Here is a snippet:

 for  (charInndex = 0; charInndex & lt; (four) strlen (theString ); CharInndex ++) {if (theString [charInndex] == '.') {TheString [CharIndex] = '\ 0'; Osi_string_copy_n (Info [Current Infoinx], 1024, The String, Synthx + 1); CurrentInfoIndex ++; TheString = & amp; TheString [चरमान + 1]; } Fourthx ++; }  

As you can see, I try to find the first event. 'Keep in mind the character and the indicator of the character. Then I 'convert' For a null variable and copy the first string into an array.

Then I want to change the indicator to start when the delimiter is found, essentially give me a new small string.

Unfortunately I'm getting an error on the line:

  theString = & amp; TheString [charInndex + 1];  

error is:

  error C2106: '=': left operation must be l-value  

me Why is there no permission to carry the indicator like this? Is my method faulty? Perhaps someone has a better idea to parse this string.

Edit: In response to comments, the declaration for the string is:

  char string [1024] = {0};  

In addition, I guarantee that the string will never exceed 1024 characters.

The assumption is that you have defined the string as an array, as an indicator Try defining when you declare a head variable as an array, you can not change your address later.

I assume that you have an announcement

  char string [100];  

The easiest solution is to leave the announcement alone, and add another:

  char * str = theString; Use  

followed by str where you currently use theString .


Comments