Click here to Skip to main content
15,926,035 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: IBM Mainframe and thousands of millions of ... Pin
David Crow2-Nov-06 10:47
David Crow2-Nov-06 10:47 
GeneralRe: IBM Mainframe and thousands of millions of ... Pin
Alexander M.,2-Nov-06 11:24
Alexander M.,2-Nov-06 11:24 
GeneralRe: IBM Mainframe and thousands of millions of ... [modified] Pin
Hamed Musavi2-Nov-06 19:41
Hamed Musavi2-Nov-06 19:41 
GeneralRe: IBM Mainframe and thousands of millions of ... Pin
David Crow3-Nov-06 2:23
David Crow3-Nov-06 2:23 
GeneralRe: IBM Mainframe and thousands of millions of ... Pin
Hamed Musavi3-Nov-06 16:26
Hamed Musavi3-Nov-06 16:26 
AnswerRe: IBM Mainframe and thousands of millions of ... [modified] Pin
Laing,James3-Nov-06 9:11
Laing,James3-Nov-06 9:11 
GeneralRe: IBM Mainframe and thousands of millions of ... [modified] Pin
Hamed Musavi3-Nov-06 16:16
Hamed Musavi3-Nov-06 16:16 
QuestionSplitting string into individual words Pin
Ramper2-Nov-06 10:18
Ramper2-Nov-06 10:18 
I need to Write a function that will, given an input string containing many words, split that string into individual words. For each word, the function should output the word, its starting index in the string, and its length to the console without using stream extraction operator.

#include <iostream>
#include <string>
using namespace std;
int main()
{

string sval = " The quick brown fox jumps over the lazy dog";

int cnt=1;
int nsep = sval.find(" ");
while (nsep > 0) {
cout << "Word " << cnt << "="
<< sval.substr(0,nsep) << endl;
cnt = cnt + 1;
sval = sval.substr(nsep+1);
nsep = sval.find(" ");

}
cout << "Word " << cnt << "=" << sval << endl;

#ifdef WIN32
system("pause");
#endif
return(0);
}


Thats where i am so far, it will just split it into words but will not work if it begins with a space or if there is more than 1 space between words. I believe i need s.find_first_not_of but not sure how to incorprate it or if thats even my problem

any help?
AnswerRe: Splitting string into individual words Pin
David Crow2-Nov-06 10:45
David Crow2-Nov-06 10:45 
GeneralRe: Splitting string into individual words Pin
Ramper2-Nov-06 11:16
Ramper2-Nov-06 11:16 
GeneralRe: Splitting string into individual words Pin
Jörgen Sigvardsson2-Nov-06 12:31
Jörgen Sigvardsson2-Nov-06 12:31 
QuestionRe: Splitting string into individual words Pin
David Crow3-Nov-06 2:24
David Crow3-Nov-06 2:24 
QuestionEncrypting an Office Document... Pin
stretchcoder2-Nov-06 9:39
stretchcoder2-Nov-06 9:39 
QuestionRe: Encrypting an Office Document... Pin
David Crow2-Nov-06 10:13
David Crow2-Nov-06 10:13 
AnswerRe: Encrypting an Office Document... Pin
stretchcoder2-Nov-06 12:20
stretchcoder2-Nov-06 12:20 
QuestionRe: Encrypting an Office Document... Pin
Maximilien2-Nov-06 10:59
Maximilien2-Nov-06 10:59 
AnswerRe: Encrypting an Office Document... Pin
stretchcoder2-Nov-06 12:22
stretchcoder2-Nov-06 12:22 
QuestionDestroyWindow - assertion failure [modified] Pin
edvintas2-Nov-06 8:57
edvintas2-Nov-06 8:57 
QuestionRe: DestroyWindow - assertion failure Pin
David Crow2-Nov-06 9:23
David Crow2-Nov-06 9:23 
AnswerRe: DestroyWindow - assertion failure Pin
edvintas2-Nov-06 9:40
edvintas2-Nov-06 9:40 
QuestionRe: DestroyWindow - assertion failure Pin
David Crow2-Nov-06 10:08
David Crow2-Nov-06 10:08 
AnswerRe: DestroyWindow - assertion failure Pin
edvintas2-Nov-06 10:56
edvintas2-Nov-06 10:56 
QuestionRe: DestroyWindow - assertion failure Pin
David Crow2-Nov-06 11:08
David Crow2-Nov-06 11:08 
AnswerRe: DestroyWindow - assertion failure Pin
edvintas2-Nov-06 11:15
edvintas2-Nov-06 11:15 
GeneralRe: DestroyWindow - assertion failure Pin
Hamid_RT2-Nov-06 18:20
Hamid_RT2-Nov-06 18:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.