Subj : Re: help with strings and functions To : borland.public.cpp.borlandcpp From : Charlie Page Date : Sat Aug 16 2003 02:45 am hope this helps, charlie //--------------------------------------------------------------------------- #include #include //--------------------------------------------------------------------------- void readsentence (char sentence[]); void cutword (char originalsent[], char word[], char sentence2[]); /* it is a good idea to list the args names with the function declaration, that way, when you look up at the top of the page for the function you want to use, you can see what char[], char[], ... should take as input. Also, note the indentation of the code. Makes it easier to read. So you can find bugs quicker, and people on message boards can figure out what you are saying easier. The first thing that I did after getting your code was indent it. */ int main(int argc, char* argv[]) { char sentence[21], word[5], sentence2[16]; readsentence (sentence); cutword (sentence, word, sentence2); } void readsentence(char sentence[]) { printf("Please type in a sentence.\n"); gets(sentence); printf("\nHere is the sentence: "); puts(sentence); } void cutword(char originalsent[], char word[], char sentence2[]) { strncpy(word, originalsent,5); /* +0 is implied*/ word[5]='\0'; puts(word); strncpy(sentence2, originalsent+5, 21); sentence2[16]='\0'; puts(sentence2); } //--------------------------------------------------------------------------- .