Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- void print(char* str);
- void printAsArray(char str[]);
- void printAsPointer(char* str );
- int main(void) {
- char* str="Hello BY Author";
- char ss[]={'H','e','l','l','o','\0'};
- print(str);
- printf("\n");
- printAsArray(ss);
- printf("\n");
- printAsArray(str);
- printf("\n");
- printAsPointer(ss);
- printf("\n");
- printAsPointer(str);
- return EXIT_SUCCESS;
- }
- void print(char* str) {
- printf("%s", str);
- }
- void printAsPointer(char* str) {
- while (*str!='\0') {
- printf("%c", *str);
- str++;
- }
- }
- void printAsArray(char* str) {
- int i=0;
- while (str[i]!='\0') {
- printf("%c", str[i]);
- i++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement