跪求简单的c语言,非常感谢啦

来源:百度知道 编辑:UC知道 时间:2024/06/04 10:02:06
1. Write a function that replaces the contents of a string with the string reversed. Test the function
in a complete program.

2 a编写一个名为trimfrnt()的函数,删除一个字符前面所有的空格
b编写一个main函数,测试a编写的函数

运行好了再给我好吗,省得我再改了
我用的VC++的软件
谢谢各位高手了

#include "stdio.h"
#include "string.h"

void trimfrnt(char* str)
{
int j=0,i;
int n=strlen(str);
while(str[0]==' ')
{
for(i=0;i<n-1;i++)
{
str[i]=str[i+1];
str[i+1]=' ';
}
j++;
}
str[n-j]='\0'; //这里决定后面要不要空格
}
int main()
{
char str[]=" xxxx";
trimfrnt(str);
printf("%s",str);
return 0;
}
你们有机会还不好好学,我现在想学都没机会了

如今的学生啊!!!
中国教育的悲哀~

1.
//---------------------------------------------------------------------------

#include <stdio.h>
#include <string.h>

void reverse(char *str)
{
int i;
char tc;
for (i = 0; i<strlen(str)-1-i; i++) {
tc=str[i];
str[i]=str[strlen(str)-1-i];
str[strlen(str)-1-i]=tc;
}
}
int main(void)
{
char s[]="id