小编Fei*_*Xue的帖子

git checkout master错误:checkout会覆盖以下未跟踪的工作树文件

我有一个git存储库.它有ABCDE ...提交.现在我想结帐D作为名为Dbranch的新分支.所以我执行:git checkout D -b Dbranch.现在我想删除这个分支.首先,我需要切换到master分支,然后使用git branch -d Dbranch它来删除它.但是当我执行时git checkout master,它会给我错误.

error: The following untracked working tree files would be overwritten by checkout:
    source/a/foo.c
        ...... (too many lines)
Please move or remove them before you can switch branches.
Aborting
Run Code Online (Sandbox Code Playgroud)

如何删除Dbranch?

git git-checkout

40
推荐指数
3
解决办法
7万
查看次数

eval()不会在运行时分配变量

我用来eval()为var分配一个列表:

eval('mylist = [1,2,3]') 
Run Code Online (Sandbox Code Playgroud)

但是当我运行它时,我得到了一个SyntaxError.它出什么问题了?如果我不能在中进行赋值eval(),如何在运行时分配var.

python string eval

8
推荐指数
1
解决办法
2671
查看次数

telnet发送http请求

我使用telnet发送http请求,如下所示:

telnet> open 192.168.4.135 8087
Trying 192.168.4.135...
Connected to 192.168.4.135.
Escape character is '^]'.
POST /rpc/ HTTP/1.1
HOST:192.168.4.135:8087
Content-length:18
Content-type:application/x-http-form-urlencoded

action=loadrsctype
HTTP/1.1 200 OK
Date: Thu, 17 May 2012 03:52:53 GMT
Content-Length: 45
Content-Type: text/html; charset=ISO-8859-1

return=fail&error=Configuration doesn't existHTTP/1.1 400 Bad Request
Content-Type: text/html
Connection: close
Date: Thu, 17 May 2012 03:52:53 GMT
Content-Length: 94

<HTML><HEAD>
<TITLE>400 Bad Request</TITLE>
</HEAD><BODY>
<H1>Bad Request</H1>
</BODY></HTML>
Connection closed by foreign host.
Run Code Online (Sandbox Code Playgroud)

响应代码是200,但为什么有这样的段落:

HTTP/1.1 400 Bad Request
Content-Type: text/html
Connection: close
Date: Thu, 17 …
Run Code Online (Sandbox Code Playgroud)

post http

7
推荐指数
2
解决办法
4万
查看次数

打印位类型为整数?如何转换?

该计划是:

typedef struct xp {
        int a:2;
        int b:2;
        int c:1;
} xp;

int main(void)
{
        xp x;
        memset(&x, 0, sizeof(xp));

        x.a = 1;
        x.b = 3;
        x.c = 1;

        printf("%d\n",x.a);
        printf("%d\n",x.b);
        printf("%d\n",x.c);

        return 0;
}
Run Code Online (Sandbox Code Playgroud)

我得到1 -1 -1,为什么?a,b和c如何存储在x中?printf("%d \n",xa)时发生了什么; 执行?

c bit

7
推荐指数
1
解决办法
278
查看次数

如何在Gentoo Linux中自动加载内核模块?

我想在启动时自动加载一些内核模块.我已阅读手册,但无法帮助.现在我要自动加载vboxdrv vboxnetadp vboxpci vboxnetflt的模块是/lib/modules/3.0.6-gentoo/,模块目录是,配置文件目录是/etc/modules.autoload.d/kernel-3.0.6,在这个文件中,模块都包含在内.现在重新启动后,使用lsmod,我看不到这些模块已加载.有什么问题?

thinkpad walle # ls -l /boot/
??? 17068
lrwxrwxrwx 1 root root       1  1? 10 01:22 boot -> .
drwxr-xr-x 2 root root    4096  4? 27 10:55 grub
-rw-r--r-- 1 root root 5771120  3? 23 09:27 kernel-3.0.6
-rw-r--r-- 1 root root 5771120  4? 26 17:48 kernel-3.0.6-n5
-rw-r--r-- 1 root root 5876784  4? 27 10:55 kernel-3.0.6-n6
drwx------ 2 root root   16384  1? 17 15:47 lost+found
Run Code Online (Sandbox Code Playgroud)

现在我kernel-3.0.6-n6用作我的启动内核.

thinkpad …
Run Code Online (Sandbox Code Playgroud)

linux gentoo kernel-module

6
推荐指数
2
解决办法
2万
查看次数

这是什么意思?(int&)a

定义一个浮点变量a,将a转换为float&和int&,这是什么意思?转换后,a是自己的参考?为什么这两个结果不同?

#include <iostream>
using namespace std;
int
main(void)
{
    float a = 1.0;
    cout << (float &)a <<endl;
    cout << (int &)a << endl;

    return 0;
}


thinkpad ~ # ./a.out 
1
1065353216
Run Code Online (Sandbox Code Playgroud)

c++

5
推荐指数
2
解决办法
1996
查看次数

我将文本读入缓冲区后如何逐行读取?

首先,我通过调用fread将文本读入缓冲区,然后我想逐行读取它,怎么做?我尝试使用sscanf,但它似乎不起作用.

char textbuf[4096];
char line[256];
FILE *fp;
fp = fopen(argv[1],"r");
memset(textbuf, 0, 4096);
fread(textbuf, 1, 4096, fp);
Run Code Online (Sandbox Code Playgroud)

我知道使用fgets是一个好方法.我只是想知道天气这种方法可以做同样的事情.

c fread

5
推荐指数
2
解决办法
3万
查看次数

两种分配方法有什么区别?

我想测试当我请求24M内存时操作系统分配了多少.

    for (i = 0; i < 1024*1024; i++)
            ptr = (char *)malloc(24);
Run Code Online (Sandbox Code Playgroud)

当我这样写的时候,我从top命令中得到RES是32M .

    ptr = (char *)malloc(24*1024*1024);
Run Code Online (Sandbox Code Playgroud)

但是当我做一点改变时,RES是244.它们之间有什么区别?为什么结果244?

c malloc

2
推荐指数
2
解决办法
176
查看次数

如何使用__malloc_hook?

GNU C Library Reference Manual中,有一个示例程序(p.65),但我不知道这三个句子__malloc_hook = old_malloc_hook; old_malloc_hook = __malloc_hook; __malloc_hook = my_malloc_hook; 是什么 意思.特别是第二个,谁能为我解释一下?谢谢.

static void *
my_malloc_hook (size_t size, const void *caller)
{
    void *result;
    /* Restore all old hooks */
    __malloc_hook = old_malloc_hook;
    __free_hook = old_free_hook;
    /* Call recursively */
    result = malloc (size);
    /* Save underlying hooks */
    old_malloc_hook = __malloc_hook;
    old_free_hook = __free_hook;
    /* printf might call malloc, so protect it too. */
    printf ("malloc (%u) returns %p\n", (unsigned int) size, result); …
Run Code Online (Sandbox Code Playgroud)

c malloc glibc

2
推荐指数
1
解决办法
4308
查看次数

如何读取格式为"123 35 123 0 0 0 817"的C中的数据

我想从字符串中读取数据.字符串是这样的:

"123 35   123 0    0      0       817 0    0   0   0"
Run Code Online (Sandbox Code Playgroud)

字符串中有一些不确定的数字和空格.我想读第三个数字.如何读取数据?

c io

2
推荐指数
1
解决办法
93
查看次数

标签 统计

c ×5

malloc ×2

bit ×1

c++ ×1

eval ×1

fread ×1

gentoo ×1

git ×1

git-checkout ×1

glibc ×1

http ×1

io ×1

kernel-module ×1

linux ×1

post ×1

python ×1

string ×1