自引用结构和引用(Self referential structs and deferencing)
如果我有以下代码,如何从根开始访问包含“left here”的字符串? (不只是使用
l->data
)。我尝试使用
root->left->data
但最终出现了seg错误,我尝试使用GDB,但我非常喜欢使用它。编辑:还有一个更好的方法来初始化指针指向的结构?
struct node { char *data; struct node *left; struct node *right; } *root, *l, *r; root->data = "root here"; root->left = l; root->right = r; l->data = "left here"; //the data I need l->left = NULL; l->right = NULL; r->data = "right here"; r->left = NULL; r->right = NULL;
If I have the following code, how do I access the string that contains "left here" starting from the root? (not just using
l->data
).I tried using
root->left->data
but ended up with a seg fault, I tried to use GDB but I'm very much a beginner in using it.EDIT: Also is there a nicer way to initialise the structs that the pointers point to?
struct node { char *data; struct node *left; struct node *right; } *root, *l, *r; root->data = "root here"; root->left = l; root->right = r; l->data = "left here"; //the data I need l->left = NULL; l->right = NULL; r->data = "right here"; r->left = NULL; r->right = NULL;
原文:https://stackoverflow.com/questions/25332682
最满意答案
萤火虫是你的朋友。 在Firefox中安装它(或在Chrome中使用Firebug Lite)。 转到您的页面,点击F12,单击元素选择工具(一个蓝色框,其中有一个箭头指向Firebug窗格右上角),然后单击有问题的项目。 在左侧,您将看到各种好的样式信息,包括文件和行号,以及(如果向下滚动)所有被一个或另一个文件覆盖的样式规则。
启蒙很快就会到来。
如果您仍有问题,请使用指向问题的实时页面链接更新您的问题,以便我们可以查看它(屏幕截图是坏像素)。
Firebug is your friend. Install it in Firefox (or use Firebug Lite in Chrome). Go to your page, hit F12, click the Element Selection Tool (a blue box with an arrow pointing into it in the upper right of the Firebug pane), then click on the offending item. On the left you will see all sorts of good style info including file and line number, and (if you scroll down) all of the style rules that were overridden by one file or another.
Enlightenment soon follows.
If you still have problems, update your question with a link to the live page with the problem so that we can go look at it (screenshots are dead pixels).
相关问答
更多-
但它也有几个空白记录(我认为这些记录与其他学校的校园记录有关)。 这些“空白”记录是为了给学校增加新的校园。 您可以使用CampusInline上的“额外”属性来控制空行数。 如果我向外键添加“unique = True”(如上面的模型所示),空白记录消失,并且看起来都很好。 不幸的是,我还在内联底部松开链接以添加新校园。 如果您在“学校”字段添加“独特”,那意味着学校只能在校园桌上出现一次。 对于外键,这通常不会(通常)很有意义。 but it also has several blank records ...
-
django-admin-tools和django-grappelli之间的比较(Comparison between django-admin-tools and django-grappelli)[2022-05-27]
django-admin-tools似乎不那么干扰。 当我检查它时,Grappelli打破了一些管理站点扩展或小部件。 也许他们修复了这个问题,但我在我的项目中使用了DAT。 django-admin-tools seems to be less intrusive. When I checked it, Grappelli broke some of admin-site extensions or widgets. Maybe they fixed it, but I'm alredy using DA ... -
删除'APP_DIRS': True,行。 Remove the 'APP_DIRS': True, line.
-
如何在django-admin-tools仪表板上添加自定义菜单项(How to add a custom menu item on django-admin-tools dashboard)[2022-02-25]
我遇到了同样的问题,并试图使用items.MenuItem像你一样,但我得到一个错误: 'MenuItem'对象没有属性'id'。 然后我来解决这个问题: 即使我们只需要一个链接,我们也应该创建LinkList link = modules.LinkList( title='', # the title is empty for better looking children=[ [_(u'My link'), reverse( ... -
Django管理问题(Django admin problems)[2022-11-23]
我的猜测是你在models.py字段中设置了auto_now_add或auto_add ,因此它首先不是你表单的一部分要排除。 尝试从exclude语句中删除它。 My guess is that you've set auto_now_add or auto_add in your models.py field, thus it's not a part of your form in the first place to exclude. Try removing it from your exclu ... -
刚按照这个文档。 http://packages.python.org/django-admin-tools/0.3.0/customization.html#customizing-the-dashboards Just followed this documentation. http://packages.python.org/django-admin-tools/0.3.0/customization.html#customizing-the-dashboards
-
是的, django.utils.markup在1.5中已弃用,在1.6中已删除。 reStructuredText标记的Python实现存在于docutils包中。 这是Django <= 1.5使用的实现。 安装docutils的最简单方法是使用pip: pip install docutils 你可以在Djangos github repo的1.5.x分支中找到旧的django.utils.markup实现: https://github.com/django/django/blob/stable/ ...
-
我在哪里为我的项目添加了django-admin-tools菜单(Where do I include django-admin-tools menu for my project)[2021-10-20]
所以菜单库本身就是另一个应用程序,可供其他应用程序和您的应用程序使用。 应用程序文件夹和项目文件夹通常位于同一文件夹中。 这是您可以使用的一种布局。 MyApp/MyApp/Template/... MyApp/App1/... MyApp/App2/... MyApp/Menu/... 或者它可以在MyApp下,其中view.py包含您的菜单代码。 MyApp/MyApp/view.py/... MyApp/MyApp/Template/... MyApp/App1/... MyApp/App2/... ... -
萤火虫是你的朋友。 在Firefox中安装它(或在Chrome中使用Firebug Lite)。 转到您的页面,点击F12,单击元素选择工具(一个蓝色框,其中有一个箭头指向Firebug窗格右上角),然后单击有问题的项目。 在左侧,您将看到各种好的样式信息,包括文件和行号,以及(如果向下滚动)所有被一个或另一个文件覆盖的样式规则。 启蒙很快就会到来。 如果您仍有问题,请使用指向问题的实时页面链接更新您的问题,以便我们可以查看它(屏幕截图是坏像素)。 Firebug is your friend. Insta ...
-
主要问题是需要截断admin_tools_dashboard_preferences (几乎每次对仪表板进行的更改都会被截断)。 此外, 文档页面上的第一段代码甚至对我无效。 我从文档的其他部分获取了片段,他们似乎没有问题。 最后,我的示例仪表板看起来像这样。 请记住截断您的偏好。 class MyDashboard(Dashboard): columns = 3 def __init__(self, **kwargs): Dashboard.__init__(self, ...