import os
ot = os.popen("%s") %"ls"
Run Code Online (Sandbox Code Playgroud)
TypeError: unsupported operand type(s) for %: 'file' and 'str'
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚为什么会发生错误.我的意思是它是纯粹的字符串操作,对吗?任何帮助都可以得到赞赏.
我是C语言的新手,我正在尝试使用如下指针.
po1
被定义为指向地址的指针.PC为其分配1个字节的内存.po2
是一样的.我想得到指向的内存地址po2
,但只得到一个意外的0
,显然不是地址.
#include <stdio.h>
int main(int argc, char *argv[]) {
char *po2, *po1;
printf("---%d---\n", po2);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出是:
demo11.c:5:23:警告:格式指定类型'int'但参数的类型>'char*'[-Wformat] printf(" - **** - %d - **** - \n",po2); 生成了~~ ^ ~~%s 1个警告. - **** - 0 - **** -
然后我试图给foo
内存po2
指向的值,但它给出了一个错误.
#include <stdio.h>
int main(int argc, char *argv[]) {
char *po2, *po1;
char foo = 'D';
*po2 = foo;
printf("%c---------------\n", *po2);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出是:
由于信号终止:分段故障(11)
显然,错误是由声明引起的*po2 = …