20kv电力工程决算书:如何用c语言编一个函数 实现字符串作参数传递,给个编译过的程序

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/30 14:59:36
#include <stdio.h>
void Lowstr(char *s)
{
char *p=s;

while(*p!='\0')
{
if(*p>='A'&&*p<='Z')
{
*p+=32;
}
++p;
}

}

void main()
{
char words[5]={'A','c','g','D','\0'};
Lowstr(words);
printf("%s\n",words);
}
这个应该可以吧

可以
给你改一下,只是形式变了一点点
void Lowstr(char *s)
{
char *p=s;
while(*p++)
{
if(*p>='A'&&*p<='Z') *p+=32;
}
}

void main()
{
char words[5]={'A','c','g','D','\0'};
Lowstr(words);
printf("%s\n",words);
}

st 传入子程序, st2 从子程序送回.
---------------------------
#include <stdio.h>
void show_st( char *st, char *st2){
printf("%s\n", st);
strcpy(st2,"new string !!");
}

void main()
{
char st[32]="This is string !";
char new_st[32];
show_st( &st[0], &new_st[0]);
printf("new string is: %s\n", new_st);
exit(0);
}

不是有八大函数吗,里面有一个函数有这个功能的