Advertisement
Guest User

Untitled

a guest
Aug 26th, 2011
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.65 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void print(char* str);
  5. void printAsArray(char str[]);
  6. void printAsPointer(char* str );
  7.  
  8. int main(void) {
  9.     char* str="Hello BY Author";
  10.     char ss[]={'H','e','l','l','o','\0'};
  11.     print(str);
  12.     printf("\n");
  13.     printAsArray(ss);
  14.     printf("\n");
  15.     printAsArray(str);
  16.     printf("\n");
  17.     printAsPointer(ss);
  18.     printf("\n");
  19.     printAsPointer(str);
  20.     return EXIT_SUCCESS;
  21. }
  22. void print(char* str) {
  23.     printf("%s", str);
  24. }
  25.  
  26. void printAsPointer(char* str) {
  27.     while (*str!='\0') {
  28.         printf("%c", *str);
  29.         str++;
  30.     }
  31. }
  32.  
  33. void printAsArray(char* str) {
  34.     int i=0;
  35.     while (str[i]!='\0') {
  36.         printf("%c", str[i]);
  37.         i++;
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement