Subj : re charlie-help with strings and functions To : borland.public.cpp.borlandcpp From : "kristine" Date : Sat Aug 16 2003 12:46 am Hi Charlie- Thanks very much for your reply. Sorry about the indentation! The program works great but I am not sure why you used command line arguments. We have not covered them in class yet and what I just read about them is a little confusing. Is char*argv pointing to char sentence[]? Is there a way to have any sentence that is read into the first function used in the second function; cutting the first word into char word[], and the rest of the sentence into char sentence2 []? Perhaps with a do while or for loop? I later have to create another function to convert the sentence typed in into pig latin, and then print it (if you can believe that!). I think that's why the professor hinted at using a loop. Thanks, again. Kristine Charlie Page wrote: hope this helps, charlie >#include >#include >void readsentence (char sentence[]); >void cutword (char originalsent[], char word[], char sentence2[]); int main(int argc, char* argv[]) { char sentence[100], word[5], sentence2[100]; readsentence (sentence); cutword (sentence, word, sentence2); } void readsentence(char sentence[]) { printf("Please type in a sentence starting with a four letter word.\n"); gets(sentence); printf("\nHere is the sentence: "); puts(sentence); } void cutword(char originalsent[], char word[], char sentence2[]) { strncpy(word, originalsent,5); word[5]='\0'; puts(word); strncpy(sentence2, originalsent+5, 21); sentence2[100]='\0'; puts(sentence2); } .