我想知道的区别stdout,并STDOUT_FILENO在Linux中C.
经过一番搜索工作,我得出以下结论.你能帮我复习并纠正错误吗?谢谢
stdout属于C语言的标准I/O流; 其类型为FILE*并在stdio.h中定义
STDOUT_FILENO拥有int类型,定义于unistd.h.它是LINUX系统的文件描述符.在unistd.h,它的解释如下:
Run Code Online (Sandbox Code Playgroud)The following symbolic constants shall be defined for file streams: STDERR_FILENO File number of stderr; 2. STDIN_FILENO File number of stdin; 0. STDOUT_FILENO File number of stdout; 1.
因此,在我看来,STDOUT_FILENO属于系统级调用,并且在某种程度上,就像系统API一样.STDOUT_FILENO可用于描述系统中的任何设备.
在stdout较高的水平(用户级?)定位和实际封装的细节STDOUT_FILENO.stdout有I/O缓冲区.
这是我对他们差异的理解.任何评论或更正都表示赞赏,谢谢.
我要将这个d3gauge.js文件导入到我的angular2组件memmon.component.ts文件中.
import '../../../../js/d3gauge.js';
export class MemMonComponent {
createMemGauge() {
new drawGauge(this.opt); //drawGauge() is a function inside d3gauge.js
}
}
Run Code Online (Sandbox Code Playgroud)
并在相应的模板文件中添加
<script src="../../../../js/d3gauge.js"></script>
Run Code Online (Sandbox Code Playgroud)
但它不起作用,drawGauge无法找到.
所以,
.ensure无法解决,因为无法解决.在Angular2中,假设我想要有条件地显示一个<div>块.以下两种方式有什么区别.
<div [hidden]=isLoaded>Hello World!</div>where isLoaded是相应.ts文件中的布尔值.
<div *ngIf=isLoaded>Hello World!</div>
我知道即使<div>页面中没有显示,1.仍然有<div>DOM中的内容,而不是.还有其他差异吗?他们每个人的利弊是什么?
我将使用Angular2接收websocket传入消息并根据收到的消息更新网页.现在,我正在使用虚拟回声websocket服务并将替换它.
根据我的理解,接收websocket消息的函数必须返回由将更新网页的处理程序订阅的observable.但我无法弄清楚如何返回一个可观察的.
代码段附于下方.在MonitorService创建一个WebSocket连接,并返回可观察到包含接收到的消息.
@Injectable()
export class MonitorService {
private actionUrl: string;
private headers: Headers;
private websocket: any;
private receivedMsg: any;
constructor(private http: Http, private configuration: AppConfiguration) {
this.actionUrl = configuration.BaseUrl + 'monitor/';
this.headers = new Headers();
this.headers.append('Content-Type', 'application/json');
this.headers.append('Accept', 'application/json');
}
public GetInstanceStatus = (): Observable<Response> => {
this.websocket = new WebSocket("ws://echo.websocket.org/"); //dummy echo websocket service
this.websocket.onopen = (evt) => {
this.websocket.send("Hello World");
};
this.websocket.onmessage = (evt) => {
this.receivedMsg = evt;
};
return new Observable(this.receivedMsg).share();
}
} …Run Code Online (Sandbox Code Playgroud) 我正在使用angular2-webpack-starter来构建我的项目,我也想使用bootstrap.
我安装ng2-bootstrap作为npm install ng2-bootstrap --save.由于ng2-bootstrap只有一些指令,它需要.css引导程序的"真实" 文件来设置它(但它的作者似乎假设我们已经拥有它),所以我安装bootstrap as npm install bootstrap --save.
现在,我的问题是如何将"真正的"引导程序.css文件导入到我的项目中,以便ng2-bootstrap可以使用它.
我试过几种方法:
将bootstrap.min.css文件从node_modules/bootstrap/dist/css文件夹复制到我的src/assets/css文件夹并添加<link href="assets/css/bootstrap.min.css" rel="stylesheet">到我的文件夹中index.html.这种方式有效,但我担心的是该bootstrap.min.css文件将不再受管理npm.我将来必须手动更新它.
另一种尝试是要求我app.component.ts这样做
styles:[require('./ app.style.css'),require('../../ node_modules/bootstrap/dist/css/bootstrap.min.css')],
但它无法解决.
import 'bootstrap';到vendor.browser.ts像刚才import '@angular/core';在里面.但它也失败了.似乎这bootstrap不是一个像@angular2/core我可以轻松导入它的包.所以,我的问题归结为如何bootstrap在webpack中导入/加载,以便它可以被ng2-bootstrap我的项目中的其他组件使用,也可以使用npm进行升级.
我尝试像这样为我的反应应用程序设置嵌套路由
/ -> 主页/about -> 关于页面/protected -> 受保护的默认页面/protected/page1 -> 受保护的第 1 页它在 codeandbox ( https://codesandbox.io/s/react-router-nested-route-utqy7 ) React 16.8.1 React Router 4.3.1 中工作正常
但是当我用 webpack-dev-server (3.7.1) 设置同样的东西时,它只能到达/而不能到达其余路由。
我的文件结构就像
??? package.json
??? src
? ??? index.jsx
? ??? index.html
??? webpack
? ??? paths.js
? ??? webpack.common.js
? ??? webpack.dev.js
??? webpack.config.js
Run Code Online (Sandbox Code Playgroud)
路径.js
const path = require('path');
module.exports = {
outputPath: path.resolve(__dirname, '../', 'build'),
entryPath: path.resolve(__dirname, '../', 'src/index.jsx'),
templatePath: path.resolve(__dirname, '../', 'src/index.html'),
};
Run Code Online (Sandbox Code Playgroud)
webpack.common.js
const webpack …Run Code Online (Sandbox Code Playgroud) 我遇到了关于多进程重定向stdout的问题.
假设我有进程A,我在A中使用fork(),然后我得到进程A和B.然后我在B中使用fork(),最后我得到进程A,B和C.B和C都在实现其他程序EXEC().
现在,我尝试用两个管道将A和B的stdout重定向到C的stdin.
#include<unistd.h>
#include<stdio.h>
#include<sty/types.h>
int main()
{
int AtoC [2];
pipe(AtoC);
int fd1,fd2;
fd1=fork();
if(fd1>0)
{
/***In process A, I do the following steps: ***/
close(AtoC[0]);
dup2(AtoC[1], STDOUT_FILENO);
/* program running in process A */
}
else
{
int BtoC [2];
pipe(BtoC);
fd2=fork();
if(fd2>0)
{
/***In process B, I do the following steps: ***/
close(AtoC[1]);
close(BtoC[0]);
dup2(BtoC[1], STDOUT_FILENO);
/*** execute another program in process B using execl(); ***/
}
else
{
/*** In process C, I do the …Run Code Online (Sandbox Code Playgroud) 我遇到了关于返回值的问题atoi().
我想将charin命令行参数argv[1]转换为int类型并将其打印出来.
这是我的代码.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int i;
//print the char in *argv[]
for(i = 0; i < argc; i++)
{
fprintf(stdout, "Arg %d: %s\n", i, argv[i]);
}
if (argc > 1)
{
i = atoi(argv[1]); //convert char to int
fprintf(stdout, "Int version of 1st arg: %d\n", i);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我用gcc编译它并运行它 ./a.out a b c
其他结果是正确的,但atoi()结果始终显示为
Int version of 1st arg: …Run Code Online (Sandbox Code Playgroud)