如何在不使用字符串函数的情况下用c两个单词串联编写程序 [英] How to write a program in c two words concatenation without using string function

查看:78
本文介绍了如何在不使用字符串函数的情况下用c两个单词串联编写程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,
如何在不使用字符串函数的情况下用c两个单词串联编写程序.

Hi DEAR,
How to write a program in c two words concatenation without using string function.

推荐答案

如果要使用纯字符指针,请分配一个具有足够内存的字符指针保留输入字符串长度的总和再加上一个用于终止空字符的长度,并从两个输入字符串中一一复制所有需要的字符.不要忘了在末尾添加一个空字符.仅当您需要生成可与可用字符串函数一起使用的字符串时,才需要这样做.如果不应该使用可用的函数来获取输入字符串的长度,请编写您自己的函数以基于对终止空字符的搜索来测量字符串的长度.

现在,它的最重要的部分:用自己的双手完成一切,因为这是获得一些基本经验并有能力在其中进行进一步操作的唯一方法软件开发.如果这是您学校的作业,请认为这是学习的机会.好好利用这个机会.

—SA
If you want to work with pure character pointers, allocate a character pointer with a memory sufficient to hold the sum of the input string lengths plus one more for terminating null character and copy all characters you need one by one from two input strings. Don''t forget to put a null character at the end. This is required only if you need to produce a string good for the use with available string functions. If you are not supposed to get lengths of input strings using available functions, write your own function to measure string length based on the search of the terminating null character.

And now, most important part of it: Do it all with your own hands, because this is the only way to get some basic experience and become capable of doing further steps in software development. If this is the assignment from your school, think of it as of a chance to learn something. Use this chance well.

—SA


这篇关于如何在不使用字符串函数的情况下用c两个单词串联编写程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆