商城首页欢迎来到中国正版软件门户

您的位置:首页 > 软件教程 >错误的C语言字符串倒序函数

错误的C语言字符串倒序函数

  发布于2025-02-03 阅读(0)

扫一扫,手机访问

C语言字符串倒序函数出错

C语言字符串倒序函数出错

展开全部

不是那个问题。

在函数my_strrev中,只有字串s的首地址,但没有对s的使用权。s是系统分配的内存空间,不能进行修改。

把string声明成为数组,或者是如下的程序都可以完成这个功能。

#include

#include

#include "malloc.h"

char *my_strrev(char *s);

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

{

// char *string = "This is a good day today";

char *string = (char*) malloc(sizeof("This is a good day today"));

strcpy(string,"This is a good day today");

char *ll=my_strrev(string);

printf("%s",ll);

free(string);

return 0;

}

char* my_strrev( char* s)

{

char *left, *right, ch;

left = right = s;

while( *right++ != '\0');

right -= 2;

while( left {

ch = *left;

*left = *right;

*right = ch;

++left; --right;

}

return s;

}

excel自定义函数遇到 value!

C3:E3是一个range变量。你函数的里面的text应该指的是文本变量,所以出现结果出错的情形。

你实际希望C3:E3代表的是C3&D3&E3

所以你要加一个for循环:

Function SUMTEXT(text as range)

Dim regEx, Match, Matches

Set regEx = CreateObject("vbScript.regexp")

regEx.Pattern = "[+-]\d+(\.\d+)?"

regEx.IgnoreCase = True

regEx.Global = True

for each c in text

t=t&c.value

next

Set Matches = regEx.Execute(t)

For Each Match In Matches

RetStr = RetStr + Val(Match)

Next

SUMTEXT = RetStr

End Function

本文转载于:https://www.docexcel.net/show/24_143124.html 如有侵犯,请联系admin@zhengruan.com删除

热门关注