c string

#include<stdio.h>

void print_string(char s[])
{
    printf("%s", s);
}

int strlen(char *s)
{
    int n;

    for(n = 0; *s != '\0'; s ++)
        n ++;
    return n;
}

int main()
{
    char s[] = "hello world!";

    for(int i = 0; i <= strlen(s); i ++){
        print_string(s + i);
        printf("\n");
    }
}

 

运行结果:

hello world!
ello world!
llo world!
lo world!
o world!
world!
world!
orld!
rld!
ld!

posted @ 2016-11-30 22:00  xkfx  阅读(170)  评论(0)    收藏  举报