Posted by: o o
May 27th,
2008
谭浩强《C语言程序设计》里面有一个动态链表的输入和输出的例子,代码如下:
#include <stdio.h>
#include <conio.h>
#include <malloc.h>
#define LEN sizeof(struct student)
struct student
{
int num;
float score;
struct student *next;
};
struct student *creat(void)
{
int N=0;
struct student *p1,*p2,*head;
p1=p2=(struct student *)malloc(LEN);
scanf("%d%f",&p1->num,&p1->score);
head=0;
while(p1->num!=0)
{
N++;
if(N==1) head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student *)malloc(LEN);
scanf("%d%f",&p1->num,&p1->score);
}
p2->next=0;
return(head);
}
void print(struct student *head)
{
struct student *p;
p=head;
if(head!=0)
do
{
printf("%d %f\n",p->num,p->score);
p=p->next;
}while(p!=0);
}
void main()
{
struct student *head1;
printf("input:\n");
head1=creat();
printf("output:\n");
print(head1);
getch();
}
用win-tc编译的时候,没有错误,可是运行的时候输入第二值后就自动关闭了,用Turbo C也一样,不过找到错误提示是scanf:floating point formats not linked. 到网上搜了搜错误原因是这样的:TC开发时(80年代)DOS下的存储资源紧缺,因此TC在编译时尽量不加入无关部分。在没发现需要做浮点转换时,就不将这个部分安装到可执行程序里。也就是说默认的情况下是不连接浮点库的,除非你需要他,这就造成了如果你没有调用浮点函数,而是直接用%f或别的形式在scanf()和peintf()里调用就会出现本例的错误——floating point formats not linked.
有两种解决办法:
1.声明一个float型的中间变量,读入,然后赋值给p->score。把第一个 scanf("%d,%f",&p->num,&p->score);
改为
float temp;
scanf("%f",&temp);
p->score = temp;
2.生明一个函数,不用调用它。
static void forcefloat(float *p)
{ float f = *p;
forcefloat(&f);
}
3.使用gcc或vc++编译器
Posted by: o o
May 23rd,
2008
5点半穿拖鞋跑出去,跑上7年前跑过的路,重新开始两年后的跑步,在看了20分钟av“思考”了人对肉体欲望的原因之后
寺山修斯的《抛掉书本上街去》跑到穿拖鞋跑步的人的脑袋里——晃来晃去,有绿色不时挤进眼里,可以听到麻雀叫
有只黑色的狗正穿过街,昨儿个中午
Posted by: o o
May 13th,
2008
网站用了cos-html-cache来静态化,所以不光想压缩css和js,连带html文件也想一块儿压缩了。原来一直用 阅微堂的方法在.htaccess里写一个规则来压缩网站的html,css和js,后来由于网站重建,同样的代码首页不能压缩了,即网站首页http://xxx/后面没有html后缀,所以无法压缩,只有http://xxx/index.html才可以正常压缩html.
所以用了一个新的方法,原来cos-html-cache好像不支持动态压缩,反正这个方法静态动态都可以正常使用,而且不和cos-html-cache冲突。
首先,在.htaccess添加以下语句:
AddHandler application/x-httpd-php .css .html .js #添加应用类型
php_value auto_prepend_file “/home/littlewi/public_html/blog/pre.php”
#相当于在每个文件前面运行pre.php,注意这里一定要填空间里的绝对地址,
不要填相对地址,我这个是cp免费空间,home是根目录,littlewi是我的用户名,
网站文件在public_html,blog装在blog目录
php_value zlib.output_compression 2048 #zlib在默认从4K开始压缩,
设成压缩到2k就开始传输
然后新建pre.php,内容如下:
<?php
#这段代码输出的是mediatype header
$pathinfo = pathinfo($_SERVER[PHP_SELF]);
$extension = $pathinfo['extension'];
switch ($extension) {
case "css" : header("Content-type: text/css");
break;
case "html" : header("Content-type: text/html");
break;
case "js" : header("Content-type: text/javascript");
break;
default : break;
}
?>
这样所有php,html,js,css都可以压缩传输,而且和cos-html-cache也不冲突。
Posted by: o o
May 12th,
2008
过日子 –巴奈
生活 梦想 现实 堕落 背叛 坚持
了解 想念 遮掩 冷漠 逃避 误解
沉淀 纠结 冷静 困顿 疯狂 无力
唱歌 跳舞 喝酒 抽烟 咖啡 做梦
专心 走路 吃饭 感觉 身体 说话
sometimes 傻笑 迟钝 sometimes 骄傲 不屑
sometimes 孤单 疲倦 sometimes 活着 it’s OK
sometimes 犯错 it’s OK sometimes 耍赖 it’s OK
sometimes 生气 it’s OK sometimes 呼吸 就够
Posted by: o o
May 6th,
2008
五月的一天可以分为四个时段:上午、下午、傍晚、夜晚。 ……