string class object

i need to know how to "write a function to count the number of lines entered using a string class object. consider a line as any sequence of characters followed by the enter key"
all i have so far is:
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
32
33
34
35
36
37
38
39
#include <iostream>
#include <stdafx.h>
#include <string>
using namespace std;
int main()


 int countLines(string stng)
{

  int index, count = 0;



  index = stng.find((char)10);   // 10 is the numerical code for Enter key



  while(index < stng.length())

  {

              if(index = stng.find((char)10, index+1))

                          count++;        // this assumes even last line 
ends w/Enter

  }
	string message;
	cout << "Enter a string:\n";
	getline(cin, count);


  return count;
  cout << "The number of strings entered is:\n"
	  << message << endl;


}
Topic archived. No new replies allowed.