Jump to content

In same line input string,number of positions and positions?

- - - - -

  • Please log in to reply
5 replies to this topic

#1
carbon

carbon

    Learning Programmer

  • Members
  • PipPipPip
  • 37 posts
Is there a way in C to in one line I input a word, than how many times a word appears in text, and all positions?

For example:

egg(word), 4(number of positions, how many time appears), 2 8 9 4(all positions in text or array)

#2
psepheroth

psepheroth

    Learning Programmer

  • Members
  • PipPipPip
  • 31 posts

Quote

Is there a way in C to in one line I input a word,..
I really don't understand this line. Perhaps there is a typo-error on this?

#3
carbon

carbon

    Learning Programmer

  • Members
  • PipPipPip
  • 37 posts
a way to input a word in one line...

#4
Flying Dutchman

Flying Dutchman

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 889 posts
  • Location:::1
Of course you can. You can read entire line as a (big) string (fgets), or use format specifier (fscanf) if you know exactly how input will look.
A conclusion is where you got tired of thinking.
#define class struct    // All is public.

#5
carbon

carbon

    Learning Programmer

  • Members
  • PipPipPip
  • 37 posts

Flying Dutchman said:

Of course you can. You can read entire line as a (big) string (fgets), or use format specifier (fscanf) if you know exactly how input will look.

User has to input word, number of positions and positions... i know that a word goes first, then a number of position, but i dont know how many positions will be there if you know what i mean.... If user input 7 (number of posizion), i must have 7 positions for him to input those positions...

eg.

word, 5, (here must enter 5 positions)
awesome, 3, (here must enter 3 positions)

#6
Flying Dutchman

Flying Dutchman

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 889 posts
  • Location:::1
Then it's best to read entire line as string and then parse the numbers.
A conclusion is where you got tired of thinking.
#define class struct    // All is public.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users