Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define SIZE 3
- void FindLastName(char* names[], char* last[], int len);
- void Print(char* names[], int len);
- void main() {
- char *names[SIZE] = { "David Bowie", "Madonna", "Bob Marley" };
- char *last[SIZE];
- FindLastName(names, last, SIZE);
- printf("The full names are:\n");
- Print(names, SIZE);
- printf("The last names are:\n");
- Print(last, SIZE);
- }
- void FindLastName(char* names[], char* last[], int len) {
- for (int j = 0, i = 0; i < len; j = 0, i++) {
- while (names[i][j] != ' '&&names[i][j] != '\0') j++;
- if (names[i][j] == ' ') j++;
- last[i] = &names[i][j];
- }
- }
- void Print(char* names[], int len) {
- for (int i = 0; i < len; i++) puts(names[i]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement