小编Lit*_*ttm的帖子

为什么strcpy会触发错误?

如果没有使用复制字符串,该程序工作正常strcpy,但我想知道原因?

#include <stdio.h>
#include <string.h>

int main ()
{

    int mat;
    char test1[20]={"Hex"} ;
    char test2[20]={"agonal"} ;

    strcpy(test1,"Diagonal"); // the print outputs the concatenated test if strcpy is commented out

    //printf("a=%c\nb=%c\n",test1[0],test1[1]);

    printf("Concatenated test=%s", strcat(test1, test2));

    return 0;
}


ERROR MESSAGE

*** buffer overflow detected ***: ./prog terminated
      ======= Backtrace: =========
      /lib/libc.so.6(__fortify_fail+0x48)[0xb75b6ae8]
      /lib/libc.so.6[0xb75b4b30]
      /lib/libc.so.6[0xb75b3dcd]
     ./prog(__gxx_personality_v0+0x14d)[0x804858d]
     ./prog(__gxx_personality_v0+0x31)[0x8048471]
      ======= Memory map: ========
Run Code Online (Sandbox Code Playgroud)

c

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

在Java中找不到Decimal Format类

我不能让这个代码工作......我不知道为什么.

它与本教程中的代码相同http://www.youtube.com/watch?v=meKpmuUI0ds&feature=related.

当这个人做的时候代码可以工作,但是我得到了这两个错误:

Test.java:4:无法结束符号符号:class decimalFormat

location:class Test

decimalFormat decFor = new decimalFormat("0.00");
Run Code Online (Sandbox Code Playgroud)

^

Test.java:4:找不到符号

符号:类decimalFormat

location:class Test

decimalFormat decFor = new decimalFormat("0.00");

                       ^
Run Code Online (Sandbox Code Playgroud)

2个错误.

这是我的代码:

public class Test {

    public static void main(String[] args) {

        decimalFormat decFor = new decimalFormat("0.00");
        double money = 15.9;
        double mula = 36.6789;
        double product = money * mula;

        System.out.println(decFor.format(product));
    }
}
Run Code Online (Sandbox Code Playgroud)

java

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

如何使用WRL返回内置winrt组件?

当我使用WRL创建winrt组件时,问题是我只能使用ABI::Windows::xxx命名空间,而且我不能Windows::UI::Xaml::Media::Imaging在WRL中使用命名空间.

那么,如何创建内置winrt组件作为返回值?

// idl
import "inspectable.idl";
import "Windows.Foundation.idl";
import "Windows.UI.Xaml.Media.Imaging.idl";

namespace Decoder
{
    interface IPhotoDecoder;
    runtimeclass PhotoDecoder;

    interface IPhotoDecoder : IInspectable
    {
        HRESULT Decode([in] int width, [in] int height, [out, retval] Windows.UI.Xaml.Media.Imaging.BitmapImage **ppBitmapImage);
    }

    [version(COMPONENT_VERSION), activatable(COMPONENT_VERSION)]
    runtimeclass PhotoDecoder
    {
         [default] interface IPhotoDecoder;
    }
}

// cpp
using namespace Microsoft::WRL;
using namespace Windows::Foundation;
using namespace ABI::Windows::UI::Xaml::Media::Imaging;
namespace ABI
{
    namespace Decoder
    {
        class PhotoDecoder: public RuntimeClass<IPhotoDecoder>
        {
            InspectableClass(L"Decoder.PhotoDecoder", BaseTrust)

            public:
            PhotoDecoder()
            {
            }

            HRESULT __stdcall Decode(_In_ int …
Run Code Online (Sandbox Code Playgroud)

c++ windows-runtime wrl

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

如何使用phonegap 2.0.0获取设备联系人?

我正在使用phonegap(Cordova 2.0.0)开发一个Android应用程序.我需要检索设备联系人.我已尝试使用此doc提供的代码

http://docs.phonegap.com/en/2.0.0/cordova_contacts_contacts.md.html#Contacts

我的代码如下

$("#shareoptions3").live('click',function(){        

    var options = new ContactFindOptions();

    options.multiple  = true; 
    var fields = ["displayName","phoneNumbers"];//["displayName", "name","phoneNumbers"];
    navigator.contacts.find(fields, onContactSuccess, onContactError, options);
});

function onContactSuccess(contacts) {//alert(contacts.length);

    for (var i=0; i<contacts.length; i++) {
        // display phone numbers
        for (var j=0; j<contacts[i].phoneNumbers.length; j++) {
            alert("Type: " + contacts[i].phoneNumbers[j].type + "\n" + 
                "Value: "  + contacts[i].phoneNumbers[j].value + "\n" + 
                "Preferred: "  + contacts[i].phoneNumbers[j].pref);
        }
    }
};

// onError: Failed to get the contacts
//
function onContactError(contactError) {
    console.log('Error in getting contacts!');
}
Run Code Online (Sandbox Code Playgroud)

我在Logcat中收到消息,如下所示: …

android cordova

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

我们如何在js中的css中添加-webkit-transform属性?

.underline {
  background-color: dodgerblue;
  display: inline-block;
  height: 2px;
  left: 50px;
  margin-top: -4px;
  position: absolute;
  top: 185px;
  -webkit-transform: scale(0, 1);
  transform: scale(0, 1);
  -webkit-transition: all 0.5s linear;
  transition: all 0.5s linear;
  width: 202px;
}
Run Code Online (Sandbox Code Playgroud)

https://codepen.io/xyaraj/pen/amzydG

我在 React 应用程序中使用 JS 中的 CSS,我想知道如何将-webkit-transitioncss 等属性放入 js 中。

const useStyles = makeStyles(() => ({
    icon: {
        padding: '.2rem .2rem',
        fontSize: '12px'
    },
    li: {
        display: 'block',
        font: 'bold 6px/12px sans-serif',
        padding: '5px 15px',
        textAlign: 'center',
        textDecoration: 'none',
        float: 'left',
    },
}
Run Code Online (Sandbox Code Playgroud)

上面的代码是我在JS中使用CSS,我想知道如何添加下划线类并添加属性-webkit-transform …

css reactjs css-in-js

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

以编程方式返回jquery-mobile navigationg

我有一个用户可以从应用程序的不同部分到达的页面.此外,通过此着陆页,用户可以导航到另一个页面并返回此着陆页.

使用默认的后退按钮功能将使用户返回该页面.简而言之,我需要在用户第一次到达此页面时保留URL,而不是changePageto此URL.

任何帮助表示赞赏.

jquery-mobile

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

当我打开infoWindow(UTF-8)时谷歌地图变得奇怪

我正在使用Google地图进行新项目,但是当我打开一个项目时,我的地图变得怪异infoWindow.

见下图:

图片描述

有人认出这个问题吗?

这是我的地图初始化代码:

$(document).ready(function(){   

    function initialize() {
        var myLatlng = new google.maps.LatLng(59.398554, 5.486206);
        var mapOptions = {
            draggable: true, 
            zoomControl: true, 
            mapTypeControlOptions: {
                mapTypeIds: [google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.HYBRID]
            }, // here´s the array of controls
            disableDefaultUI: true, // a way to quickly hide all controls
            scrollwheel: false,
            zoom: 13,
            center: myLatlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        }

        var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);

        var contentString = '<div id="content">'+
            '<div id="siteNotice">'+
            '</div>'+
            '<h2 id="firstHeading" class="firstHeading">FjørSilkeBris</h2>'+
            '<div id="bodyContent">'+
            '<p>Førland, 5570 Aksdal</p>'+
            '<p>481 49 246 …
Run Code Online (Sandbox Code Playgroud)

javascript google-maps

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

通过LinkedList.Enumerator替换LinkedList元素值

我意识到我无法通过替换价值LinkedList.Enumerator.

例如,我尝试将以下Java代码移植到C#:

Java代码:

ListIterator<Double> itr1 = linkedList1.listIterator();
ListIterator<Double> itr2 = linkedList2.listIterator();
while(itr1.hasNext() && itr2.hasNext()){
    Double d = itr1.next() + itr2.next();
    itr1.set(d);
}
Run Code Online (Sandbox Code Playgroud)

C#代码:

LinkedList<Double>.Enumerator itr1 = linkedList1.GetEnumerator();            
LinkedList<Double>.Enumerator itr2 = linkedList2.GetEnumerator();

 while(itr1.MoveNext() && itr2.MoveNext()){                
    Double d = itr1.Current + itr2.Current;
    // Opps. Compilation error!
    itr1.Current = d;
}
Run Code Online (Sandbox Code Playgroud)

我可以使用的任何其他技术?

c# java

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

检查字段中的字母和数字字符

我正在尝试编写javascript代码,以确保我的表单中的字段的前2个字符为字母(US),其余8个为数字.

总数必须是10,如果不满足任何一个,我应该抛出一个警告框.

我现在正在检查数字,但我不知道如何在同一字段中组合检查字母和数字.

这是我检查数字的代码.

请帮帮我!sid是我的字段名称.

// only allow numbers to be entered
var checkOK = "0123456789";
var checkStr = document.forms[0].sid.value;
var allValid = true;
var allNum = "";

for (i = 0; i < checkStr.length; i++)
{
    ch = checkStr.charAt(i);
    for (j = 0; j < checkOK.length; j++)
        if (ch == checkOK.charAt(j))
            break;

    if (j == checkOK.length)
    {
        allValid = false;
        break;
        if (ch != ",")
            allNum += ch;
    }
    if (!allValid)
    {
        alert("Please enter only 8 numeric …
Run Code Online (Sandbox Code Playgroud)

javascript regex validation

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

如何将数学mysql查询应用于数据库中的每一行?

我正在为MMORPG和管理员后端设计数据库.我需要一个允许我添加指定数量的游戏主要货币的功能:Gold到数据库中的每个帐户.

这就是我所拥有的:

function massAddGold($gold_amount){
    dbconnect();
    $value=mysql_query("SELECT * from `mmo_db1`.`users`;");
    while ($row=mysql_fetch_array($value)){
        $currentgold=$row['gold'];
        $newgold=$currentgold+$gold_amount;
        mysql_query("UPDATE  `mmo_db1`.`users` SET  `gold` =  \"$newgold\";");
    }
    dbclose();
}
Run Code Online (Sandbox Code Playgroud)

where mmo_db1是数据库的名称.

当我执行命令时,massAddGold("50");我然后检查数据库.它采用具有最高值的行Gold,将其添加50 gold到该行,然后将该值应用于所有行.我需要它分别在每一行上执行.

php mysql

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