Advertisement
Guest User

FTFY

a guest
Nov 16th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.19 KB | None | 0 0
  1. //Will Coast
  2. //CS 2060.002
  3. //Assignment 5
  4. //Due 20 November 2018\
  5. //long desc
  6.  
  7. #include <stdio.h>
  8.  
  9. void printArray(char * arrayPtr);
  10.  
  11. int main () {
  12.  
  13.     char * arrayPtr[] = {"echo","charlie","delta","alpha","beta"};
  14.  
  15. //welcome message + description of program
  16.     printf("Welcome to Will Coast's array of string pointers assignment.\nIn this program, we will first print "
  17.            "our predetermined, unsorted array. \nWe will then sort it alphabetically with a sorting function and reprint it with the same print function.\n");
  18.     printf("We will do this by using a while loop inside a for loop inside our print function.\n");
  19.  
  20.     printArray(*arrayPtr);
  21. //sortArray
  22. //printArray;
  23.  
  24.  
  25.     return 0;
  26.  
  27. }
  28.  
  29. void printArray (char * arrayPtr) {
  30.  
  31.     for (int i = 0; i < 30; i++) {
  32.  
  33.         char *temp = &arrayPtr[i];
  34.         if(arrayPtr[i] == '\0'){
  35.             printf("\n------\n");
  36.             continue;
  37.         }else{
  38.             printf("%c/", arrayPtr[i]);
  39.         }
  40.  
  41.         //this while loop prints the word letter by letter until it runs into a nul character.
  42. //        while (*temp != '\0') {
  43. //            printf("%c", *(temp));
  44. //            temp++;
  45. //        }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement