Advertisement
horselurrver

Ch11 Ex2

Aug 8th, 2016
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. char * arrays(char *string, int n);
  4. int main(void){
  5.     char *ptr2;
  6.     ptr2=arrays("hi whassup", 5);
  7.     int i;
  8.     for(i=0; i<5; i++){
  9.         printf("%c", *(ptr2+i));
  10.     }
  11.     printf("\n");
  12.     return 0;
  13. }
  14.  
  15. char * arrays(char *string, int n){
  16.     char array2[80];
  17.     char *ptr2;
  18.     ptr2=array2;
  19.     int i;
  20.     for(i=0; i<n; i++){
  21.         *(ptr2+i)=string[i];
  22.         if (isspace(string[i]))
  23.             break;
  24.     }
  25.     return ptr2;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement