input and sub-strings

i am writin a program that accepts a string of characters, maximum size 30, with a % signifying the end of the input string. Ask the user to designate the number of sub-strings from 1 to 7 inclusive. Display the resulting output from each of the designated sub-strings. Do not include the % as one of the characters.

Sample Input and Output:
Input String: wshoocskes%
Input Number of sub-strings: 2
Output from sub-string 1: whose
Output from sub-string 2: socks

Input String: tajaomonmyen%
Input Number of sub-strings: 4
Output from sub-string 1: tom
Output from sub-string 2: amy
Output from sub-string 3: joe
Output from sub-string 4: ann

i am not sure what to do?
First get out a piece of paper and pencil and do it yourself a couple of times, so that you have an idea of how it works. Remember to keep track of how you are indexing the string.

Good luck!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// strchar.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{

	char name[30]; // stores sum of integers 1 to 10
   int x = 1; 
   int sum = 0;// counter
   cout << "Hello, how are you doing today?" << endl;
   cout << "Please enjoy the following program" << endl;
   cout << "Please enter a input string" << endl;
   cin.getline(name, 30, '%');
   
   cout << "The string entered was: " << name << endl;
     
  

   /*while ( x <= 10 ) // loop 10 times
   {
      sum += x; // add x to sum
      x++; // increment x
   } // end while
*/
   system("PAUSE");

	return 0;
}
anyone with any suggestions
How about the suggestions I gave you?

Do that a couple times and when it is firm in your head what is happening (and from you penultimate post, I don't think you are sure how it is supposed to work) --only then can you do the assignment.

Programming is instructing the computer how to do something you already know.

If you are having serious problems with that, you need to schedule a time to visit with your professor for some extra help.
Topic archived. No new replies allowed.