strlen.c源代码

2013-02-06

// strlen.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int
main (int argc, char *argv[])
{

char *s;
//if ( argc != 2 )
if (argc < 2 || argc > 2)
{
s = argv[0];
printf ("Please Usage: %s STRING\n", s);
return 0;
}
else
{
s = argv[1];
printf ("%s has %d chars\n", s, strlen (s));
return 0;
}

return 0;

}
// gcc -o strlen strlen.c

分类:Linux操作系统编程 | 标签: |

相关日志

评论被关闭!