954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Strings

Hey,
I have to write a function that does this :
It checks if a word come up twice in a row .
For example :
myString[] = " Ariel lives in in the city city Ariel "

so now my function should print the words : in city .
because they are words that appear twice , notice that Ariel should not be printed because the word Ariel doesn't appear 1 after another.

pls help me solve this .
Thanks ahead ,
Nickol .

Nickol
Newbie Poster
3 posts since Feb 2006
Reputation Points: 10
Solved Threads: 0
 

No.

If you don't solve this problem yourself, you won't be solve the problem that comes after this one, or the problem that comes after that. You'll might be able to squeak by with a passing grade, but you'll have learned nothing.

Rashakil Fol
Super Senior Demiposter
Team Colleague
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 177
 

I'm trying for 2 days to do so ..
But i'm so confused by the loops that i created .
Here's what i was trying to do :

const int SIZE=35;
int main()
{
int Length;
int counter=0;
char secString[SIZE];
char myString[SIZE] = "Ariel is in in the city city Ariel";
cout<=0;j--)
{
secString[j] = myString[j];
cout<<"secString is : "<

Nickol
Newbie Poster
3 posts since Feb 2006
Reputation Points: 10
Solved Threads: 0
 

Use [code] [/code] tags.

You can use C++-style strings and the find() function. Or you can use strstr(). Or you can stick with for loops.

Hint: ignore chars until you reach a space (or until isspace() (in /) returns non-zero).

dwks
Posting Whiz in Training
269 posts since Nov 2005
Reputation Points: 185
Solved Threads: 28
 

Try something like this....

<<sudocode>>
first = true;
In a for loop, using the char array...
  if (first) {
    build a string of chars in 'temp1' until there is a space
    and set first = false;
  }
  then build a string in 'temp2' until space.
  now compare temp1 to temp2. If they match, print temp1
  copy temp2 into temp1
  repeat
}
Nedals
Light Poster
43 posts since Dec 2005
Reputation Points: 11
Solved Threads: 0
 

Thank you ,
Appriciated .

Nickol
Newbie Poster
3 posts since Feb 2006
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You