Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GetWords function 1

Status
Not open for further replies.

idinkin

Programmer
Sep 12, 2002
29
IL
Hi all!
I want to create a function that will recieve a sentence (string) as an argument and return an array of words. Could you tell me please how can I do this? (The part of splitting the sentence to words is already ready but I have a problem with returning an array of words).
 

Maybe you dont have to return an array of words,instead you can pass them as an argument of your function.
Code:
#define _MAXSTRING_   100

void splitFunction( char* string, char word[][_MAXSTRING_] )
{
    ....
    ...
    strcpy( word1,word[0] );
    strcpy( word2,word[1] );
    ....
    ..
}

I think that you should get the idea.
 
sorry i meant:

#define _MAXSTRING_ 100

void splitFunction( char* string, char word[][_MAXSTRING_] )
{
....
...
strcpy( word[0], word1 ); // the changes are here
strcpy( word[1], word2 );
....
..
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top