Is this possible? I would like to have a user input a sentence, and then have each word in that sentence be put into its own array.
Loopah
0
Junior Poster in Training
Recommended Answers
Jump to PostYes it is possible.
Jump to Postmake use of string class and its functions...it is very easy
Jump to PostI was talking about <string>
Jump to PostPost your attempt. The basics are something like this:
static const char delim[] = " \n"; size_t size = 0; char word[10][20], *ptr = strtok(sentence, delim); while ( ptr != NULL ) { strcpy(word[size], ptr); if ( ++size >= sizeof word / sizeof *word ) { break; …
All 16 Replies
WolfPack
491
Posting Virtuoso
Team Colleague
SpS
34
Posting Pro
Loopah
0
Junior Poster in Training
SpS
34
Posting Pro
Loopah
0
Junior Poster in Training
Dave Sinkula
2,398
long time no c
Team Colleague
Loopah
0
Junior Poster in Training
Loopah
0
Junior Poster in Training
Dave Sinkula
2,398
long time no c
Team Colleague
Loopah
0
Junior Poster in Training
Dave Sinkula
2,398
long time no c
Team Colleague
Loopah
0
Junior Poster in Training
Dave Sinkula
2,398
long time no c
Team Colleague
Loopah
0
Junior Poster in Training
Dave Sinkula
2,398
long time no c
Team Colleague
Loopah
0
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.