小编ron*_*nan的帖子

在字符串中搜索垃圾字符

我想将以下代码集成到主应用程序代码中.填充了o/p字符串的垃圾字符转储应用程序以下代码snipette不起作用..

void stringCheck(char*);

int main()
{
    char some_str[] = "Common Application FE LBS Serverr is down";
    stringCheck(some_str);
}


void stringCheck(char * newString)
{
    for(int i=0;i<strlen(newString);i++)
    {
        if ((int)newString[i] >128)
        {

TRACE(" JUNK Characters in  Application Error message FROM DCE IS = "<<(char)newString[i]<<"++++++"<<(int)newString[i]);

        }
    }
}
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我更好的方法来找到字符串中的垃圾字符..

非常感谢

c++

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

关于在C++代码中使用realloc实现的问题

在我们的C++中,Iam目前使用realloc方法来调整malloc分配的内存大小.realloc()的使用如下所示

my_Struct *strPtr =(my_struct*)malloc(sizeof(my_Struct));

/* an later */

strPtr = (my_struct*)realloc(strPtr,sizeof(my_Struct)*NBR);
Run Code Online (Sandbox Code Playgroud)

现在wikipeadia(_http://en.wikipedia.org/wiki/Malloc)说

如果相反的话

void *p = malloc(orig_size);

/* and later... */

p = realloc(p, big_size);
Run Code Online (Sandbox Code Playgroud)

然后,如果不可能获得big_size字节的内存,p将具有值NULL并且我们不再有指向先前为p分配的内存的指针,从而产生内存泄漏

它还说纠正上述错误的正确方法是

void *p = malloc(orig_size);

/* and later... */

void *tmp = realloc(p, big_size); 

if (tmp != NULL)
 {

p = tmp; /* OK, assign new, larger storage to p */

} 

else 

{

/* handle the problem somehow */

}
Run Code Online (Sandbox Code Playgroud)

你能告诉我使用realloc()的最佳方法是什么

一旦我有一个结构的指针,然后在使用realloc后,我可以使用指针到一个空格???

非常感谢

c++ memory-management realloc

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

Java代码中的Cyclomatic Complexity为11(允许的最大值为10)

我有以下java代码违反checkstyle说" Cyclomatic Complexity是11(允许的最大值是10)"

 public boolean validate(final BindingResult bindingResult) {
        boolean validate = true;
        for (String channel : getConfiguredChannels()) {
            switch (channel) {
            case "SMS":
                // do nothing
                break;
            case "Email":
                // do nothing
                break;
            case "Facebook":
                // do nothing
                break;
            case "Voice":
                final SpelExpressionParser parser = new SpelExpressionParser();
                if (parser
                        .parseExpression(
                                "!voiceMessageForm.audioForms.?[audioId == '' || audioId == null].isEmpty()")
                        .getValue(this, Boolean.class)) {
                    bindingResult.rejectValue("voiceMessageForm.audioForms",
                            "message.voice.provide.all.audios");
                    validate = false;
                }
                boolean voiceContentErrorSet = false;
                    boolean voiceDescriptionErrorSet = false;
                    for (AudioForm audioForm : (List<AudioForm>) …
Run Code Online (Sandbox Code Playgroud)

java

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

使用JQuery自动刷新DIV

我的要求是每5秒自动刷新一次DIV

我要刷新的DIV内容是

<div class="row-fluid">
    <div class ="span2">
        <label><spring:message code='total.registration' />:</label>
    </div>
    <div class = "span3">
        ${registrationStatusForm.totalRegis}
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我还检查了一些关于stackoverflow的问题但是不明白.请注意我正在使用Spring Web MVC.请建议.

javascript ajax jquery

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

单击按钮重置所有Formdata

我的重置按钮代码是

<div class="span6 pagination-right">
            <input id="clearData" type="button" class="btn"  data-add-person-manually-reset="#"
                value=<spring:message code="common.reset" />>&nbsp;&nbsp;&nbsp;
            <input type="button" class="btn"
                data-add-manually="/recipient/person/add"
                value=<spring:message code="common.add" />>
            </div>
Run Code Online (Sandbox Code Playgroud)

我想清除以下字段使用jQuery重置div id Clear1和Clear 2字段以清除调用Reset is From div id Clear1

  1. firstName lastname组织职位

    **From div id Clear2**
    codeval1
    codeval2
    codeval3
    codeval4
    codeval5
    addressList5.type
    
    Run Code Online (Sandbox Code Playgroud)

                <div class="row-fluid" id="addToGroup">
                                    <div
                                        class="row-fluid form-inline control-group<c:if test='${empty groups}'> hidden</c:if>"
                                        id="addToGroupForm">
                                        <label class="control-label">Add to Group:&nbsp;</label>
                                        <div class="controls" id="showGroups">
                                            <div class="span9">
                                                <select class="span9" id="addGroupId">
                                                <option value="0" disabled selected><spring:message code="group.select"/></option>
                                                    <c:forEach var="group" items="${groups}">
                                                        <option value="${group.id}">${group.name}</option>
                                                    </c:forEach>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div …
    Run Code Online (Sandbox Code Playgroud)

javascript jquery

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

ConfigMap 有一个数据库名称数组作为数据

朋友们

我正在编写一个包含 postgres 数据库名称数组的 configMap。方法 1 会抛出一个错误,例如 postgres.db.name 中需要标量值

apiVersion: v1
kind: ConfigMap
metadata:
  name: postgres-init
data:
  postgres.host: "postgreshost"
  postgres.db.name: {"postgredb1","postgredb1", "postgredb3"}
Run Code Online (Sandbox Code Playgroud)

这是方法 2,即 postgres.db.name 的数据库名称以逗号分隔

----
apiVersion: v1
kind: ConfigMap
metadata:
  name: postgres-init
data:
  postgres.host: postgreshost
  postgres.db.name: postgredb1,postgredb1,postgredb3
Run Code Online (Sandbox Code Playgroud)

将数据库名称实现为数组的正确方法是什么?

kubernetes

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

退格和删除按钮不会删除IE上的textarea中的字符

在我的应用程序中,我有一个文本区域,用户无法删除使用退格键输入的字符或使用IE9中的删除键.这适用于Chrome.

我有以下代码

$('textarea').live('keydown', function(e) {
        var keyCode = e.keyCode || e.which;
        if (keyCode == 9) {
            var currentIndex = getCaret($(this).get(0))
            selectText($(this), currentIndex);
            return false;
        }
    });
});
Run Code Online (Sandbox Code Playgroud)

我使用jQuery.highlighttextarea.js突出显示模式上的单词.我不确定是否 需要修改jQuery.highlighttextarea.js来处理退格或删除.请建议

我确实用过它

我确实用过它

if (e.which == 9) {
var currentIndex = getCaret($(this).get(0))
            selectText($(this), currentIndex);
            return false;
    }

if (e.which == 8 || e.which == 46)  {
    return false;

}
Run Code Online (Sandbox Code Playgroud)

但是现在退格或删除不起作用

javascript jquery internet-explorer

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