小编use*_*779的帖子

最大宽度:100% 不工作

我正在尝试做一个类似聊天的事情,它具有以下结构:

<div class="chat">
    <div id="messagesWrap" class="chat-messages">
        <table id="chat">
            <tr>
                <td>
                    A certain long text, whos length overflows the "chat" container div.
                </td>
            </tr>
            //some more <tr><td> pairs go here with JS.
        </table>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

另外,我有以下 CSS:

.chat
{
    position: absolute;

    min-width: 400px;
    width: 20%;
    height: 100%;
    left: 0;
    right: auto;
    top: 0;
    bottom: 0;
}

.chat-messages
{
    width: 100%;
    max-width: 100%;
    height: calc(100% - 40px);
    overflow-x: hidden;
    overflow-y: scroll;
}

#chat
{
    height: 100%;
    max-width: 100%;
}

#chat>tbody
{
    max-width: …
Run Code Online (Sandbox Code Playgroud)

html css web

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

GDB的奇怪行为

我一直在尝试调试一些小东西,并且在尝试这样做时几乎疯了.经过几个小时的解决问题后,我终于得到了一段代码,这是我问题的根源:

#include <iostream>
#include <vector>
#include <stack>

using namespace std;

int main()
{
    std::vector<int> foo = std::vector<int>();

    foo.push_back(0);
    foo.push_back(11);
    foo.push_back(222);
    foo.push_back(3333);

    std::stack<int> bar = std::stack<int>();

    cout << endl << foo.size() << endl << endl;

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

有了这个编译,使用:

g++ -std=c++11 -ggdb -O0 -pedantic -Wall -Wextra -Wno-nonnull -fkeep-inline-functions
Run Code Online (Sandbox Code Playgroud)

然后我尝试以下方法:

(gdb) br 18
Breakpoint 1 at 0x40170c: file ./....cpp, line 18.
(gdb) r
Starting program: ...
[New Thread 15620.0x3c3c]

Breakpoint 1, main () at ./....cpp:18
18              cout << endl << foo.size() << …
Run Code Online (Sandbox Code Playgroud)

c++ gdb

6
推荐指数
1
解决办法
166
查看次数

在Windows上的C中获取当前工作目录

出于某些奇怪的原因,当我尝试将函数get_current_dir_name与MinGW GCC编译器一起使用时,我在链接上得到了这个结果:

undefined reference to `get_current_dir_name'
collect2.exe: error: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

但是,我只在使用这样的函数时得到这个

printf("%i", get_current_dir_name());
Run Code Online (Sandbox Code Playgroud)

或这个

printf("%s", get_current_dir_name());
Run Code Online (Sandbox Code Playgroud)

当我尝试做的时候

printf(get_current_dir_name());
Run Code Online (Sandbox Code Playgroud)

我得到了这个,这没有任何意义,因为该函数返回一个char*,根据文档:

tester.c: In function 'main':
tester.c:16:2: warning: passing argument 1 of 'printf' makes pointer from integer without a cast [enabled by default]
  printf(get_current_dir_name());
  ^
In file included from tester.c:1:0:
c:\mingw\include\stdio.h:294:37: note: expected 'const char *' but argument is of type 'int'
 _CRTIMP int __cdecl __MINGW_NOTHROW printf (const char*, ...);
Run Code Online (Sandbox Code Playgroud)

Google似乎真的不喜欢谈论C,因为我可以找到如何在几乎任何现有语言上获得workdir,除了C.唯一弹出的是一些描述3个函数的文档:getcwd,getwd和get_current_dir_name.我真的想使用get_current_dir_name,因为它的清洁度.

我该如何处理?这是minGW的错误吗?或者我错过了什么?

c windows gcc mingw ld

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

标签 统计

c ×1

c++ ×1

css ×1

gcc ×1

gdb ×1

html ×1

ld ×1

mingw ×1

web ×1

windows ×1