Help!

  • dman999
  • Born
  • Born
  • dman999
  • Posts: 1

Post 3+ Months Ago

I know this might be simple for some, but I'm just learning C. I need to be able to Input a line with at least 2 words, count the number of the occurrences of
the first word in that line, then print it out. After that, replace every occurrence of the
first word in that line with the second word. Then print out the new line. Assume
that spaces are word separators. You don't need to consider tabs. The name of your
program should be replace.c.

For example,
Output> Input a line with at least 2 words:
Input> abc def abc opqr stuvwxyz def abcdef babcdef abc
Output> The number of the occurrences of the first word "abc" is:3
The new line after substitution is:
def def def opqr stuvwxyz def abcdef babcdef def
Note: we don't replace abcdef with defdef, since here abc is a part of the word abcdef,
but it is not a word.
  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Posts: 4581
  • Loc: Maryland

Post 3+ Months Ago

I could do that in PHP, but don't know it in C++ sorry :(
  • Katushai
  • Graduate
  • Graduate
  • User avatar
  • Posts: 152

Post 3+ Months Ago

youre saying youre using C right? ive never seen input and output used in that language...maybe youre thinking of C++.....try putting puts or gets instead of input or output....or printf and scanf. that should work.
  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Posts: 4581
  • Loc: Maryland

Post 3+ Months Ago

he is just using input and output for the example.

Persay,

The computer outputs....
The user inputs...
  • blackhat
  • Novice
  • Novice
  • blackhat
  • Posts: 26

Post 3+ Months Ago

Are you doing C for fun or for a class of some sort? There really isn't a need to do C if your just going to learn C++ afterwards...why? Because when you start C++ you have to drop a lot of what you thought you knew from C, crazy isn't it?

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 43 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.