函数返回字符串数组

编程入门 行业动态 更新时间:2024-10-26 14:33:07
本文介绍了函数返回字符串数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我创建了一个函数,你发送一个字符串,并根据空格进行标记,所以我给它发一个字符串给它返回一个字符串数组,但是在函数的声明中它表示 错误C2470:''splitter'':看起来像一个函数定义,但是没有参数列表;跳过明显的身体 和 错误C2092:''splitter''数组元素类型无法正常运行 我的标题是 字符串拆分器[](字符串行) i前几天读取的返回值可以是任何长度,只要它的一个对象, int,string,array,只要它是一个对象,那么我做错了什么? 提前感谢

解决方案

i创建了一个函数,你发送一个字符串,并根据空格进行标记,所以我给它发一个字符串给它返回一个字符串数组,但是在声明中它说的功能 错误C2470:''splitter'':看起来像一个函数定义,但是没有参数列表;跳过明显的身体 和 错误C2092:''splitter''数组元素类型无法正常运行 我的标题是 字符串拆分器[](字符串行) i前几天读取的返回值可以是任何长度,只要它的一个对象, int,string,array,只要它是一个对象,那么我做错了什么? 提前感谢

,因为spliter [],你不能将数组元素类型作为返回值。将其更改为* spliter并且它将起作用。 Savage

<非常感谢

非常感谢:D它工作了 一切正常,功能明智,但是当我打电话给它时,我收到了这个错误 警告C4172:返回本地变量的地址或临时的 你真高兴知道为什么会这样吗?非常感谢

我想我必须用公共功能宣布它,我做了,但现在我得到一个新的错误, 1> retrieveGeoCmdCmd.obj:错误LNK2019:未解析的外部符号" class std :: basic_string< char,struct std :: char_traits< char>,class std :: allocator< char> > __cdecl splitter(类std :: basic_string< char,struct std :: char_traits< char>,class std :: allocator< char>>)" (?分离器@@ YA?AV?

i created a function which u send a string, and it tokenizes according to spaces, so i send it a string for it to return me a string array, but on the declaration of the function it says error C2470: ''splitter'' : looks like a function definition, but there is no parameter list; skipping apparent body and error C2092: ''splitter'' array element type cannot be function and my header is string splitter[](string line) i read the other day that the return value could be anythin as long as its one object ,int, string, array, as long as its one object, so what am i doing wrong? thanks in advance

解决方案

i created a function which u send a string, and it tokenizes according to spaces, so i send it a string for it to return me a string array, but on the declaration of the function it says error C2470: ''splitter'' : looks like a function definition, but there is no parameter list; skipping apparent body and error C2092: ''splitter'' array element type cannot be function and my header is string splitter[](string line) i read the other day that the return value could be anythin as long as its one object ,int, string, array, as long as its one object, so what am i doing wrong? thanks in advance

it''s because of spliter[],you cannot have array element type as a return value.Change it to *spliter and it will work. Savage

thanks a lot :D it worked it all worked, function wise, but when i call it, i get this error warning C4172: returning address of local variable or temporary do u happpen to know why that is?? thanks a lot again

well i figured i had to have it declared withthe public functions, which i did, but now i get a new error, 1>retrieveGeoCmdCmd.obj : error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl splitter(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?splitter@@YA?AV?

更多推荐

函数返回字符串数组

本文发布于:2023-10-28 05:31:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1535671.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数组   字符串   函数

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!