我想Octopress
在我的电脑上安装.我试着这样做
我跑的时候
bundle install
Run Code Online (Sandbox Code Playgroud)
我收到了错误消息
An error occured while installing RedCloth (4.2.9), and Bundler cannot continue.
Make sure that `gem install RedCloth -v '4.2.9'` succeeds before bundling.
Run Code Online (Sandbox Code Playgroud)
所以,我跑了
sudo gem install RedCloth -v '4.2.9'
Run Code Online (Sandbox Code Playgroud)
然后,我再次收到错误消息:
ERROR: Error installing RedCloth:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:1:in `<main>'
Run Code Online (Sandbox Code Playgroud)
我没有学过任何关于红宝石的知识.
这是我的 main.c
......
int main(int argc, char **argv)
{
init_arg(&argc, &argv);
......
}
Run Code Online (Sandbox Code Playgroud)
这是我的 init_arg.c
......
void init_arg(int *argc, char ***argv)
{
printf("%s\n", *argv[1]);
......
}
Run Code Online (Sandbox Code Playgroud)
我编译它没有错误和警告.
我跑了:
./a.out include
它会出现Segmentation故障
当我调试它时,我发现了一步 printf("%s\n", *argv[1]);
弄错了,它显示:
print *argv[1]
Cannot access memory at address 0x300402bfd
我想知道,如何打印argv[1]
的init_arg()
功能.
Django版本是1.4.我读过了official document
,并用谷歌搜索了我的问题.
首先我按照官方文档管理静态文件添加到settings.py
:
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
)
Run Code Online (Sandbox Code Playgroud)
在我的模板中:
<link href="{{ STATIC_URL }}css/main.css" ...>
Run Code Online (Sandbox Code Playgroud)
但是,在我的broswer是:
<link href="css/main.css" ...> (Just render `STATIC_URL` as empty)
Run Code Online (Sandbox Code Playgroud)
我的设置是:
STATIC_ROOT = os.path.join(PROJECT_PATH, 'static')
STATIC_URL = '/static/'
Run Code Online (Sandbox Code Playgroud)
在我的 views
def register(request):
...
return render_to_response('register.html', {'errors':errors})
Run Code Online (Sandbox Code Playgroud) 功能的原型ctime
是
char *ctime(const time_t *timep);
Run Code Online (Sandbox Code Playgroud)
我们可以看到,它返回一个字符串.但是,哪里有刺痛?
为什么我们不应该释放字符串的内存
这是示例代码将获得大量错误消息
char *p;
p = ctime(...);
...
free(p);
Run Code Online (Sandbox Code Playgroud)
***glibc检测到***./a.out:free():指针无效:0x00007f0b365b4e60***
我的家乡世界是写一个壳.我必须使用$PS2
.
但是当我写这样的代码时:
char *ENV_ps2;
ENV_ps2 = getenv("PS2");
Run Code Online (Sandbox Code Playgroud)
我刚发现ENV_ps2
是指向的(null)
.
我怎么能得到$PS2
我的程序?
这是我正在使用的文件的文本:
(4 spaces)Hi, everyone
(1 tab)yes
Run Code Online (Sandbox Code Playgroud)
当我运行此命令时 - grep '^[[:space:]]+' myfile
它不会向stdout打印任何内容.
为什么它不匹配文件中的空格?
我正在使用GNU grep版本2.9.
这是我的代码.这很简单.
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
void *func(void *arg)
{
printf("ID=%d\n", *(int*)arg);
pthread_exit(NULL);
}
int main()
{
pthread_t pt[4];
int i;
for (i = 0; i < 4; i++)
{
int temp = i;
pthread_create(&pt[i], NULL, func, (void*)&temp);
}
sleep(1);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我编译了它:
gcc p_test.c -lpthread
我跑了 它印了2 2 3 3
.我又跑了 它印了2 3 3 2
.
我的问题是:
为什么2
或3
打印两次?
为什么没有打印1 3 2 0
或任何其他结果?
我正在尝试使用以下程序来显示从端口收到的消息8888
.我编译了以下代码,没有任何错误和警告.
运行后,我用broswer打开 127.0.0.1:8888
然后,控制台显示:
read: Transport endpoint is not connected
read: Transport endpoint is not connected
Run Code Online (Sandbox Code Playgroud)
我调试它,但我找不到原因.
Linux内核3.x Ubuntu 64位
#include <stdio.h>
#include <netdb.h>
#include <string.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <netinet/in.h>
//#include <errno.h>
int main(int argc, char *argv[])
{
int sock;
char buf[BUFSIZ+1];
buf[BUFSIZ] = '\0';
uint16_t port = (uint16_t)atoi("8888");
struct sockaddr_in ser;
memset(&ser, 0, sizeof(ser));
ser.sin_port = htons(port);
ser.sin_addr.s_addr = htonl(INADDR_ANY);
ser.sin_family = AF_INET;
sock = …
Run Code Online (Sandbox Code Playgroud) 我知道,w+
既指read
和write
,然后我写这样的代码来读取一个txt文件的一些消息,并写了一些消息进去
这是我的代码:
f = open('test', 'w+')
f.write('yes yes yes\n')
print f.read()
......
f.close()
Run Code Online (Sandbox Code Playgroud)
当我运行它时,它只打印换行符,并且没有打印 yes yes yes
然后我打开test
文件,我发现yes yes yes
它在里面!
为什么它只是打印新行,但打印yes
,以及w+
&之间的区别是什么r+
错误消息是:
Using the URLconf defined in Blog.urls,
Django tried these URL patterns, in this order:
^admin/doc/
^admin/
^post/ ^post/(?P<post_id>\d+)/$
The current URL, post/1458/, didn't match any of these.
Run Code Online (Sandbox Code Playgroud)
为什么?我认为post/1485/
匹配^post/(?P<post_id>\d+)/$
我的根URL配置是:
urlpatterns = patterns('',
...
url(r'^post/', include('posts.urls')),
)
Run Code Online (Sandbox Code Playgroud)
然后,我posts/urls.py
是:
urlpatterns = patterns('',
...
url(r'^post/(?P<post_id>\d+)/$', 'post.views.post_page'),
)
Run Code Online (Sandbox Code Playgroud)