CodeLab


Write a sequence of statements that finds the first comma in the string line , and assigns to the variable clause the portion of line up to, but not including the comma. You may assume that an int variable pos , as well as the variables line and clause , have already been declared.

Is there a way that I can do this and remember the concept? Is there someone who can explain this in a way that no matter what string objects there are, there is a basic concept that I can get in order to do other string objects problems, I only have three more to go. I know I'm not exactly the sharpest tool in the shed, but please help me if you can.
If you are allowed to use standard C functions then you can use strchr to find the comma and strncpy to copy the substring. Or you can write a loop yourself to do the task.

I have not understood what is the meaning of the variable pos in your assignment. Also it is not clear what to do if there is no any comma in the string line.:)
Last edited on
I don't know whether there's concept. I can think of three or four different ways to tackle this. But I reckon at this stage you're just supposed to learn how to step through an array one element at a time.
Topic archived. No new replies allowed.