Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 136853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:00:50+00:00 2026-05-11T07:00:50+00:00

I am faced with the need to pull out the information in a string

  • 0

I am faced with the need to pull out the information in a string of the format ‘blah.bleh.bloh’ in ANSI C. Normally I would use strok() to accomplish this, but since I am getting this string via strtok, and strtok is not thread-safe, I cannot use this option.

I have written a function to manually parse the string. Here is a snippit:

for(charIndex=0; charIndex < (char)strlen(theString); charIndex++) {     if(theString[charIndex] == '.')     {         theString[charIndex] = '\0';         osi_string_copy_n(Info[currentInfoIndex], 1024, theString, charIndex + 1 );         currentInfoIndex++;         theString = &theString[charIndex + 1];     }     charIndex++; } 

As you can see, I try to find the first occurrence of ‘.’ and make note of the index of the character. Then I convert the ‘.’ to a null char and copy the first string to an array.

Then I want to change the pointer to start just after where the delimiter was found, essentially giving me a new shorter string.

Unfortunately I am getting an error on the line:

theString = &theString[charIndex + 1]; 

The error is:

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

Why am I not allowed to move the pointer like this? Is my method flawed? Perhaps someone has a better idea for me to parse this string.

EDIT: In response to the comments, the declaration for theString is:

char theString[1024] = {0}; 

Also, I am guaranteed that theString will never be more than 1024 characters.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T07:00:51+00:00Added an answer on May 11, 2026 at 7:00 am

    Under the assumption that you defined theString as an array, try defining it as a pointer. When you declare a char variable as an array, you cannot later change its address.

    I am assuming you have a declaration similar to

    char theString[100]; 

    The easiest solution is to leave that declaration alone, and add another one:

    char *str = theString; 

    and then use str everywhere that you currently use theString.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to convert several Java classes to C#, but I have faced few
We're often faced with the need to send a data file to one of
I am faced with the following issue. I need to capture a range of
I'm faced with a situation where I'm reading a string of text and I
I've faced with situation when I need to have EF readonly property in case
I need to run a regex match over a file, but I'm faced with
I am currently faced with a problem where I need to execute a batch
I need to input face and get facial, faces, faced, facing, facer, faceable etc.
I'm faced with a situation in JavaScript when I need to update an object
I need to flip an image so that a character faces in the right

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.