我练习了一个没有初始值的字符串数组.
#include <stdio.h>
char *array[] = {};
int main(int argc, char *argv[]) {
array[0]="Hello";
array[1]="World";
char **i = array;
while (*i) {
printf("%d %s\n", i, *i);
i++;
}
}
Run Code Online (Sandbox Code Playgroud)
$ gcc array_of_strings.c && ./a.out
6293704 Hello
6293712 World
Run Code Online (Sandbox Code Playgroud)
它工作正常.
我以为我可以在主函数中移动数组指针.
#include <stdio.h>
int main(int argc, char *argv[]) {
char *array[] = {};
array[0]="Hello";
array[1]="World";
char **i = array;
while (*i) {
printf("%d %s\n", i, *i);
i++;
}
}
Run Code Online (Sandbox Code Playgroud)
$ gcc array_of_strings.c && ./a.out
-1899140568 (j??
-1899140560 World
-1899140552 …Run Code Online (Sandbox Code Playgroud) Html5元素有一个新属性,可拖动,并像这样使用它.
http://www.w3.org/TR/2011/WD-html5-20110405/dnd.html
<div draggable="true">foo</div>
Run Code Online (Sandbox Code Playgroud)
它还接受带有参数鼠标事件的ondrag事件.
<div draggable="true" ondrag="drag(event)">foo</div>
Run Code Online (Sandbox Code Playgroud)
我的问题是; 有没有办法设置拖动边界,所以我只能水平拖动,就像在JQuery,http://jqueryui.com/draggable/#constrain-movement.
不使用JQuery ..仅使用Javascript ..
嗨,我正在尝试使用angularjs开发一个应用程序和我发现的实例GMaps指令:http://nlaplante.github.io/angular-google-maps/#!/usage .我遵循所有步骤,但我无法渲染地图!它没有返回任何错误!救命!!
在HTML中
<html ng-app="Maptesting">
Run Code Online (Sandbox Code Playgroud)
<google-map center="center"
zoom="zoom"
markers="markers"
refresh="!isMapElementHidden"
style="height: 400px; width: 100%; display: block;">
</google-map>
<div ng-view></div>
Run Code Online (Sandbox Code Playgroud)
<script type="text/javascript" src="js/angular/angular.js"></script>
<script src="http://code.angularjs.org/1.2.0-rc.2/angular-route.min.js"></script>
<script type="text/javascript" src="js/angular-google-maps.js"></script>
<script src="http://maps.googleapis.com/maps/api/js?sensor=false&language=en"></script>
<script src="app/map.js">
</script>
Run Code Online (Sandbox Code Playgroud)
在控制器中:
angular.module('Maptesting', ['google-maps'])
.controller('CtrlGMap', ['$scope', function($scope) {
$scope.center = {
latitude: 45,
longitude: -73
};
$scope.markers = [];
$scope.zoom = 8;
}])
Run Code Online (Sandbox Code Playgroud) javascript google-maps google-maps-api-3 angularjs angularjs-google-maps
每当用户访问网站时,我都试图让我的背景图像成为可能.我在stackoverflow上找到了一些代码,但我似乎无法让它工作.
这段代码有什么问题?
码:
$(document).ready(function() {
var bgArray = ['A-VOLTE.jpg', 'AL-DI-LA.jpg', 'CON-TE.jpg', 'DAVIDE-E-GOLIA.jpg', 'DELLE-VERITA.jpg', 'DI-NOI.jpg', 'DIVIDERE.jpg', 'FA-NIENTE.jpg', 'FORSE.jpg', 'GRAZIE.jpg', 'IL-CONTATTO.jpg', 'IL-PONTE.jpg', 'IMPERATIVO.jpg', 'INDELEBILE.jpg', '-VOLONTA.jpg', 'MERITAVI.jpg', 'MUOVERE.jpg', 'NEL-DUBBIO.jpg', 'NESSUNO.jpg', 'NON-LO-SAI.jpg', 'PER-DIMENTICARE.jpg', 'PRIMA-DI-ANDARE.jpg', 'PROFONDO.jpg', 'SARA-SUO.jpg', 'SEMPRE.jpg', 'TUTTO-DA-RIFARE.jpg', 'TUTTO-PER-TE.jpg', 'UN-RICORDO.jpg', 'UNTITLED-1.jpg', 'UNTITLED-2.jpg', 'VERO.jpg', 'VIENI-CON-ME.jpg'];
var bg = bgArray[Math.floor(Math.random() * bgArray.lenght)];
// If you have defined a path for the images
var path = 'artworks/abstract/';
var imageUrl = path + bg;
// then you can put it right before the variable 'bg'
$('body').css('background-image', 'url(' + …Run Code Online (Sandbox Code Playgroud) C的新手,并尝试创建自己的第一个库.然而,gcc说找不到图书馆.使用-L/lib/path,它应该没问题,但事实并非如此.
仅供参考,我使用的是Mac OS x.
~/c$make
gcc -c -o obj/hellomake.o src/hellomake.c -I./include
gcc -c -o obj/hellofunc.o src/hellofunc.c -I./include
gcc -o hellomake obj/hellomake.o obj/hellofunc.o -I./include -L./lib -lm -llibfunc
ld: library not found for -llibfunc
collect2: ld returned 1 exit status
make: *** [hellomake] Error 1
~/c$ls ./lib
README.txt libfunc.a libfunc1.c libfunc1.o libfunc2.c libfunc2.o
Run Code Online (Sandbox Code Playgroud) 在以下两种情况下,这有什么区别?
情况1
var Person = function() { this.name="Allen Kim" }
Person.name; //undefined
Run Code Online (Sandbox Code Playgroud)
案例2
var Person = function() { this.name="Allen Kim" }
var me = new Person();
me.name // Allen Kim
Run Code Online (Sandbox Code Playgroud)
只想了解这个范围如何适用于这两种情况.