//1string.c
#include <string.h>
#include <ctype.h>
char* format(char* str)
{//isupper,islower,isdigit,isspace,isblink,isalpha,...
if(str==NULL||*str=='\0')
return str;
char* s = str;
*str = toupper(*str);//tolower
while(*++str)
*str = tolower(*str);
return s;
}
//1string.h
#ifndef _1STRING_
#define _1STRING_
char* format( char* str );
#endif
//2int.c
int bits(unsigned int d)
{
int cnt=1;
while(d>=10){
d /= 10;
cnt++;
}
return cnt;
}
//2int.h
#ifndef _2INT_
#define _2INT_
int bits(unsigned int d);
#endif
//3static.c
#include <stdio.h>
#include "1string.h"
#include "2int.h"
int main()
{
char s[]="good morNinG, everyONe.";
puts(format(s));
printf("%d\n", bits(1234567));
return 0;
}
//4so.c
#include <stdio.h>
#include "1string.h"
#include "2int.h"
int main()
{
char s[]="hello";
puts(format(s));
printf("%d\n", bits(789));
return 0;
}
UNIX 下C編程 代碼01
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.