在C中计划和组织应用程序的最佳方法是什么?

编程入门 行业动态 更新时间:2024-10-27 10:32:45
本文介绍了在C中计划和组织应用程序的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我只需要在C中编写几次,似乎每次我做,它变成一些难以管理的野兽。

I've only had to code in C a few times, and it seems like every time I do, it becomes some unmanageable beast.

我已经完成我的大部分编程在C#和.Net中,所以我非常习惯于类风格的架构,但我似乎无法掌握在C应用程序中的组织。我应该把与某个文件相关的功能放在一个文件中,将功能定义放在一个文件中,另一个处理在另一个文件中。在这个问题上有没有什么好的资源?

I've done most of my programming in C# and .Net so I am very accustomed to the class style architecture, but I can't seem to grasp organization in C applications. Should I put functions that are related in a certain file, put function definitions in one file and processing in another, etc. Are there any good resources out there on this subject?

另请参见:与面向对象的土地挣扎着C?

推荐答案

以下是可能有助于您的类比:

Here is an analogy that might help you:

一个类是某种数据结构和一组访问和操作该数据的函数。 c 语言不提供任何合成糖来为您组织此关系,但您仍然可以围绕这个想法构建代码。所以,只要这样做:设计你围绕一堆课程进行设计。

A class is a data structure of some kind and a set of functions to access and manipulate that data. The c language doesn't provide any syntatic sugar to organize this relationship for you, but you can still build your code around this idea. So, just do it: design you project around a bunch of "classes".

代码组织通常采用两种形式之一:

Code organization generally takes on one of two forms:

  • 每个函数都得到一个头文件(接口)文件,一个 .h 扩展名和一个 .c extension
  • 每个类(即相关函数集)都会获得一个头文件和一个实现文件。
  • Each function gets one header (interface) file with a .h extension and one implementation file with a .c extension
  • Each "class" (i.e. set of related functions) gets one header file and one implementation file.

所以,你已经知道如何做...

So, you already know how to do this...

更多推荐

在C中计划和组织应用程序的最佳方法是什么?

本文发布于:2023-11-08 11:47:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1569285.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   组织   计划   方法

发布评论

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

>www.elefans.com

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