Physics and Astronomy |
Back to top
On this page
Contents Simple text exercisesRemember that a "writeable string" is just an array of characters and that at this stage we assume that anything read from the keyboard such names etc. do not have spaces. You may assume that all names are 10 characters or less. Read in a name, print it out
Several names
A functionSplit the above into two parts: read in the names inside main() then pass (the address of) the two-dimensional array to a function to do the second part. A length comparisionNow write a second function that also gets passed (the address of) the two-dimensional array. Have this function ask for a minimum length and print out all the names this long or longer. An alphbetical comparisionNow write a third function that also gets passed (the address of) the two-dimensional array. Have this function print out every name that is alphabetically before the first one. You should use strcmp(). Log in |