小编Sim*_*mon的帖子

汇编程序与C程序的大小几乎相同

例如:我创建了一个简单的C程序,打印"Hello,World",编译它并创建了一个大小为39.8Kb的可执行文件.

按照这个问题,我能够创建等效的但是用汇编写的,这个程序的大小是39.6Kb.

这让我感到非常惊讶,因为我期望汇编程序比C程序小.正如问题所示,它使用了C头和gcc编译器.这会使装配程序更大还是它们大致相同的大小是正常的?


使用strip命令我减少了两个文件.这删除了调试代码,现在两者都有非常相似的文件大小.两者都是18.5Kb.

test.c的:

c windows assembly executable filesize

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

PHP 警告:strpos():search.php 中的空针

我有一个 php 搜索文件,它在目录中搜索具有提交名称的文件并显示结果。我想在与 php 代码相同的文件中使用 html 表单,即在 search.php 中仅像这样:

<form action="search.php" method="get"><input name="q"
type="text"> <input type="submit"></form>

<?php
$dir = '/www/posts'; 
$exclude = array('.','..','.htaccess'); 
$q = (isset($_GET['q']))? strtolower($_GET['q']) : ''; 
$res = opendir($dir);

while(false!== ($file = readdir($res))) { 
    if(strpos(strtolower($file),$q)!== false &&!in_array($file,$exclude)) 
    { 
        $last_dot_index = strrpos($file, ".");
        $withoutExt = substr($file, 0, $last_dot_index);
        echo "<a href='$withoutExt'>$withoutExt</a>"; 
        echo "<br>"; 
    }
}  
closedir($res); 
?>
Run Code Online (Sandbox Code Playgroud)

但上面的代码给出了错误:Warning: strpos(): Empty needle in search.php on line 10

我尝试使用!empty这样的论点:

<?php
$dir = '/www/posts'; 
$exclude = array('.','..','.htaccess'); 
$q …
Run Code Online (Sandbox Code Playgroud)

php

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

每当我使用" - ="代替"+ ="时,为什么python会给出错误消息?

令人费解的是,我可以在12号线使用+=操作员代替-=无问题.

程序:

message = input("Enter a Message: ")

new_message = ""

VOWELS = "aeiou"
print()
for letter in message:
    if letter.lower() not in VOWELS:
        new_message -= letter



print("A new string has been created:", new_message)
print("Your message without vowels is:", new_message)

input("\n\nPress the enter key to exit.")
Run Code Online (Sandbox Code Playgroud)

错误信息:

Traceback (most recent call last):
  File "C:\Python31\no vowels (from book).py", line 12, in <module>
    new_message -= letter
TypeError: unsupported operand type(s) for -=: 'str' and 'str'
Run Code Online (Sandbox Code Playgroud)

编辑:如果我听起来无知,忘了提,我是编程的新手

python python-3.x

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

这里发生了什么?与人们在人们打印人循环

people = ['mago','pipa','john','mat']
>>> for people in people:
    print(people)


mago
pipa
john
mat
>>> for people in people:
    print(people)


m
a
t
>>> for people in people:
    print(people)


t
>>> for people in people:
    print(people)


t
>>> for people in people:
    print(people)


t
>>> for people in people:
    print(people)
Run Code Online (Sandbox Code Playgroud)

python for-loop

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

标签 统计

python ×2

assembly ×1

c ×1

executable ×1

filesize ×1

for-loop ×1

php ×1

python-3.x ×1

windows ×1