问题描述
定义一个行字符串的结构并实现一个函数,该函数接受一个行字符串并返回行字符串的总长度。
我是什么尝试过:
stringLength(struct string * s)
{
返回s- >长度;
}
Define a structure for a line string and implement a function that takes a line string and returns the overall length of the line string.
What I have tried:
stringLength(struct string *s)
{
return s->length;
}
推荐答案
struct string
因为它可能有一个有长度的成员,但仔细阅读它也可能是最大尺寸。比Dirk的解决方案与字符串数据。
我想你需要学到很多东西来提高你的编码技巧。花时间学习,否则你会失败。谷歌的一些教程或阅读你的学校文件练习。
祝你好运
because it may have a member which has the length, but read carefully it could also be the max size. Than the the solution of Dirk with the string data.
I guess you need to learn a lot to improve your coding skills. Take time and learn or you will fail. Google for some tutorial or read your school documents an practise .
Good luck
stringLength(struct string *s)
{
int i=0;
while(s[i] != '\0') i++;
return i;
}
这篇关于实现一个函数,该函数接受一个行字符串并返回行字符串的总长度。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!