我刚遇到的一些旧代码:
MLIST * new_mlist_link()
{
MLIST *new_link = (MLIST * ) malloc(sizeof(MLIST));
new_link->next = NULL;
new_link->mapi = NULL;
new_link->result = 0;
}
Run Code Online (Sandbox Code Playgroud)
这被称为构建一个链表,但我注意到没有声明:
return new_link;
Run Code Online (Sandbox Code Playgroud)
即使没有返回语句,列表仍然可以正确构建.为什么会这样?
编辑:平台:Mandriva 2009 64位Linux 2.6.24.7-服务器GCC 4.2.3-6mnb1
编辑:有趣......这段代码也成功运行了大约5种不同的Linux安装,所有不同的版本/风格,以及Mac.
我想知道封隔器与缩放器的区别/好处是什么,即你应该在你的网络应用程序中部署打包或缩小版本?
示例代码:
var layout = {
NAVVISIBLE : 1,
Init : function()
{
this.Resize();
},
Dimensions : function()
{
var d = document, s = self, w, h;
if (s.innerHeight)
{ w = s.innerWidth; h = s.innerHeight; }
else if (d.documentElement && d.documentElement.clientHeight)
{ w = d.documentElement.clientWidth; h = d.documentElement.clientHeight; }
else if (d.body)
{ w = d.body.clientWidth; h = d.body.clientHeight; }
return new Array(parseInt(w), parseInt(h));
},
Resize : function()
{
var dim = this.Dimensions();
try
{
$('tbl_container').width = px(dim[0] …Run Code Online (Sandbox Code Playgroud) 有一个网站我试图从Perl中提取信息,但我需要的页面部分是使用javascript生成的,所以你在源代码中看到的是:
<div id="results"></div>
Run Code Online (Sandbox Code Playgroud)
我需要以某种方式提取该div的内容并使用Perl/proxies/whatever将其保存到文件中.例如,我想保存的信息将是
document.getElementById('results').innerHTML;
Run Code Online (Sandbox Code Playgroud)
我不确定这是否可能,或者是否有人有任何想法或方法来做到这一点.我正在使用lynx源转储到其他页面,但由于我不能直接屏幕刮这个页面我来这里询问它!
如果有人有兴趣,页面是http://downloadcenter.trendmicro.com/index.php?clk=left_nav&clkval=pattern_file®s=NABU,我试图得到的信息是关于ConsumerOPR的行
我试图保持bar_top_container div不包装它的内容,无论页面有多宽(即两个选择应该总是出现在同一条线上),但这不起作用,但是当页面宽度很小时它们都适合它们在一条线上,我该如何解决这个问题?
样式:
#bar_top_container { position: relative; white-space: nowrap; }
#bar_top_block { float: left; padding-left: 10px; padding-right: 10px; border-right: 1px solid #4965BB; }
#clear { clear: both; }
Run Code Online (Sandbox Code Playgroud)
HTML:
<div id="bar_top_container">
<div id="bar_top_block">
<span class="bold">select1: </span>
<select><option value="asdf">asdf</option></select>
</div>
<div id="bar_top_block">
<span class="bold">asdf: </span>
<select><option value="blah">-- select action --</option></select>
</div>
<div id="clear"></div>
</div>
Run Code Online (Sandbox Code Playgroud) 我以为我理解地图然而以下结果我不明白.我知道为什么会这样,我只是不知道它是怎么回事.
问题是@array的内容正在改变,因为$_在_do_stuff_to_file调用期间正在重置.所以印刷的是here: \nhere:\n我期待它的时候here: donkie\nhere: kong\n.
注意:这不是经过测试的代码.这就是我记得从实验室看到的东西.为什么内容会@array改变?
如果我在返回1之前设置$_为.然后阵列仍然完好无损.$f_some_func
这是一个示例程序来说明我所看到的:
my @array = ("donkie", "kong");
map { push @junk, _some_func('blah', $_); } @array;
if (join ('', @junk) !~ /0/)
{ # for example sake this is always true since return 1 from _some_func.
print map { "here: $_\n"; } @array;
}
sub _some_func
{ # for example sake, lets say $f always exists as a file.
my …Run Code Online (Sandbox Code Playgroud) 可以说我有以下内容:
CHARLINK * _init_link(CHARLINK **link)
{
short i;
(*link)->cl = (CHARLINK **) calloc(NUM_CHARS, sizeof(CHARLINK *));
for (i = 0; i < NUM_CHARS; i++)
(*link)->cl[i] = NULL;
return (*link);
}
Run Code Online (Sandbox Code Playgroud)
循环是将每个元素初始化为NULL还是从calloc自动为NULL?
在我问任何事情之前,让大家知道这很有趣,我已经发布了我迄今为止所有的代码; 随着事情的修复/实施,会发布更多内容,对于冗长的帖子感到抱歉!
我在这里有两个问题,我将在下面发布我的所有代码.
现在它只是一个基于文本的程序,最多可接受26个字母,并输出200K字+字典中的所有有效单词:
http://www.calvin.edu/~rpruim/scrabble/ospd3.txt
下面的C程序要求将字典切成26个文件,其中包含每个文件中每个字母开头的所有单词(文件'a'等等中的所有单词...)perl将在下面发布.
Word Finder(c):
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define NUM_CHARS 26
#define MAX_WORD_LEN 20
#define WORDS_PER_LINE 12
/* Character link structure */
typedef struct char_link
{
struct char_link **cl; /* All of this links possible next characters */
short eow; /* END OF WORD (means this is the last letter of a valid word */
} CHARLINK;
/* Global found word count, used for printing '\n' char. */
unsigned short gwc = …Run Code Online (Sandbox Code Playgroud) $hi = do_this('asdf');
sub do_this
{
$blob{'f'} = {
'k' => 'j'
};
}
print $hi->{'k'};
# prints j
Run Code Online (Sandbox Code Playgroud)
因为do_this没有返回任何东西,它怎么还打印j?
这可能是什么问题?无论我选择什么数字为str,它始终是26815615859885194199148049996411692254958731641184786755447122887443528060147093953603748596333806855380063716372972101707507765623893139892867298012168192.00
char *str = "2.6";
printf("%f\n", strtof(str, (char**)NULL));
//prints 26815615859885194199148049996411692254958731641184786755447122887443528060147093953603748596333806855380063716372972101707507765623893139892867298012168192.00
Run Code Online (Sandbox Code Playgroud)
整个计划:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char *str = "2.6";
printf("%f\n", strtof(str, NULL));
return 1;
}
Run Code Online (Sandbox Code Playgroud)
用-Wall编译:
test4.c:7: warning: implicit declaration of function âstrtofâ
Run Code Online (Sandbox Code Playgroud)