小编Nav*_*lam的帖子

将stdout和stderr恢复为默认值

在shell脚本中,我们可以使用exec命令将默认输入更改为File,如下所示:

  exec 1>outputfile
Run Code Online (Sandbox Code Playgroud)

但是,如果我想在同一个脚本中将stdout描述符'1'恢复为默认值(终端).我们怎样才能做到这一点?

linux shell redirect stdout exec

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

用C++命名Mangling

我正在阅读这篇文章 - http://www.geeksforgeeks.org/extern-c-in-c/

给出了两个例子 -

int printf(const char *format,...);

int main()
{
    printf("GeeksforGeeks");
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

它说这不会编译因为编译器无法找到'printf'函数的错位版本.但是,下面给出输出.

extern "C"
{
    int printf(const char *format,...);
}

int main()
{
    printf("GeeksforGeeks");
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

这是因为extern"C"阻止名称被破坏.但是,代码运行并提供输出.从哪里得到'printf'的定义.我读了一篇帖子,默认包含'stdio.h'.如果是这样,则必须运行以下代码.但是,它给出了未定义printf的错误.

int main()
{
    printf("GeeksforGeeks");
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

有人可以解释一下吗?

c++ extern

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

标头中没有Content-type!尝试访问我的Web服务时出错

我正在使用jboss 4.2服务器处理Eclipse上的Web服务示例。我创建了一个服务实现类,如下所示:

import java.util.HashMap;
import java.util.Map;

import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService
public class CarWebServiceImpl  {

    private final Map<String, Integer> prices = new HashMap<String, Integer>();

    public CarWebServiceImpl() {
        prices.put("audi", Integer.valueOf(10000));
        prices.put("bmw", Integer.valueOf(150000));
        prices.put("fiat", Integer.valueOf(5000));
    }

    @WebMethod
    public Response getCarPrice(String carId) {
        int price = prices.get(carId);
        Response resp = new Response();
        resp.setPrice(price);
        return resp;
    }

}
Run Code Online (Sandbox Code Playgroud)

Web服务自动部署到服务器中,我可以在以下位置看到我的服务

http://127.0.0.1:8080/jbossws/services/
Run Code Online (Sandbox Code Playgroud)

我创建了另一个项目,并使用了wsconsume实用程序来生成客户端类文件。然后,我将服务类实例化如下:

public class Client {
    public static void main(String[] args) {
        CarWebServiceImplService service = new CarWebServiceImplService();
        CarWebServiceImpl port = service.getCarWebServiceImplPort();
        port.getCarPrice("audi");
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试运行客户端代码时,出现以下错误 …

java eclipse jboss web-services

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

使用atof功能有什么问题?

int main()
{
    char str[10]="3.5";
    printf("%lf",atof(str));
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

这是我在ideone.com上测试的一个简单代码.我得到的输出为

-0.371627
Run Code Online (Sandbox Code Playgroud)

c atof

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

标签 统计

atof ×1

c ×1

c++ ×1

eclipse ×1

exec ×1

extern ×1

java ×1

jboss ×1

linux ×1

redirect ×1

shell ×1

stdout ×1

web-services ×1