c string

#include<stdio.h>

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

int strlen(char *s)
{
    int n;

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

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

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

运行结果:

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

原文地址:https://www.cnblogs.com/xkxf/p/6119884.html