我正在搜索关于"C程序如何工作"的博客文章一个月.大多数人都喜欢
我想我会先阅读有关编译器如何理解程序流入机器的工作原理.龙书似乎是普遍的首选.但说实话,这太过密集了.我现在还不够好,无法完成所有这些工作.
所以我开始阅读有关硬件的内容.但是,他们也解释了总线,I/O信号,内存结构,编写缓存友好代码等等.但没有适当的例子.
但我仍然无法让自己满意或能够完全想象这个过程.
2个小时前,我决定提出这个问题.(因为我害怕它可能对SO社区,或题外话题或其他可下注的类别没用),而且我没有找到任何与此相关的帖子.有一个关于"编译器如何编译",但答案表明这是一个太宽泛的问题.
我的问题是:
我想知道C程序的工作原理.如果您无法明确告诉我,请将我重定向到另一个网站上的书或其他帖子,以便给我答案.
我在这里,直到得到回复.如果您对此帖有任何建议,请告诉我.这不是我的第一语言,所以请把我所有的句子都当作柔软和礼貌的.
谢谢.
更新:
除了接受的答案外,还有一些非常好的链接以及建议,可以给出部分答案或进一步了解我想要了解的内容.
今天我尝试编写一个程序,该程序将接受一段文本并创建一个显示不同单词之间关系的图表.一切顺利,除了我不知道如何以更好的方式找到联系.更好的方式意味着类似于思维导图.这是一个简单的输入,但我想创建一个程序,可以从维基百科中获取一个段落,并给出一个非常好的思维导图.我从以下输入的程序的点格式输出中得到的图表是
roses are red line_end
sky is blue line_end
life is beautiful line_end
everything is going fine line_end file_end
Run Code Online (Sandbox Code Playgroud)

但是对于像这个输入这样的输入,它只是创建了一个非常大的图形,它比文本本身更加模糊.
Probability is a measure of the likeliness that an event will occur line_end
Probability is used to quantify an attitude of mind towards some proposition of whose truth we are not certain line_end
file_end
Run Code Online (Sandbox Code Playgroud)

所以我的问题是,在这种情况下,什么算法可以正常工作.我应该学习什么才能制作这样的节目.下面是我的C++程序.(我还使用ruby进行文本处理,以"line_end"和"file_end"获取当前形式的段落,但这不是我遇到问题的地方)
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#define MP(X,Y) (make_pair<string,string>(X,Y))
using namespace std;
map<string, vector<string> > mind_map;
set<string> ignore_these_words;
set<pair<string,string> > already_discovered;
string black_list[] = {"and","is","are","was","for","the","a","an","or","under","up","over","beside","below", …Run Code Online (Sandbox Code Playgroud) 我试图生产使用简单二叉树插入GIF动画dot和convertUbuntu的公用事业.但它并不是我想要的完全正常工作.我在最后得到的动画gif没有显示完整的树,只显示了根节点.
要测试程序,只需输入一些随机整数并用-1停止输入部分.
#include<stdio.h>
#include<stdlib.h>
struct node{
int value;
struct node *left,*right;
};
typedef struct node node;
node *root;
FILE *out;
node *insert(node *,int);
node *new_node(int);
int main()
{
root = NULL;
int temp;
int k = 0;
while(1)
{
scanf("%d",&temp);
if( temp == -1) break;
root = insert(root,temp);
take_snap(k++); // this function writes the dot file and create a jpg image for the current tree
}
animate();
// this function use convert utility to combine all …Run Code Online (Sandbox Code Playgroud)