当我尝试运行此程序时,我收到一个错误,该程序暂停程序并说"向量下标超出范围"
知道我做错了什么吗?
#include <vector>
#include <string>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
using namespace std;
//(int argc, char* argv[]
int main()
{
fstream bookread("test.txt");
vector<string> words;
bookread.open("test.txt");
if(bookread.is_open()){
cout << "opening textfile";
while(bookread.good()){
string input;
//getline(bookread, input);
bookread>>input;
//string cleanedWord=preprocess(input);
//char first=cleanedWord[0];
//if(first<=*/
//cout << "getting words";
//getWords(words, input);
}
}
cout << "all done";
words[0];
getchar();
}
Run Code Online (Sandbox Code Playgroud) 我是JS的新手.我试图让我成为一个书签,在网页上找到所有图像并为它们添加彩色边框.然后,通过单击图像我想附加图像路径.这是我到目前为止所得到的:
javascript:
for (var i= document.links.length; i-->0;) {
if (document.links[i].getElementsByTagName('img').length!=0) {
document.links[i].onclick= function() {
window.open("http://www.example.com/whatever?imgsrc=" + this.src + "");
};
}
}
Run Code Online (Sandbox Code Playgroud)
如何为图像添加边框?
谢谢,鲍勃
我们在业余时间使用当时可用的最新mvc3和Entity Framework .net库构建了一个小应用程序,并进行了部署.管理层喜欢它,他们希望将它集成到繁重的.net 3.5 Web表单应用程序中.
我需要以某种方式在两个应用程序中使用相同的身份验证会话.我使用相同的数据库和应用程序使用.net成员资格和配置文件提供程序进行身份验证.这样可以正常工作,但即使用户已经登录主应用程序,用户也必须单独登录MVC应用程序.我对任何建议持开放态度:在不同级别启用状态会话,或共享cookie等
绕过此登录要求的最佳方法是什么?是否应将mvc应用程序集成到webforms中或将其保留为独立应用程序?影响决策的主要问题是完成集成所需的时间,以及以后的应用程序维护.
我知道有关ios上的nsurlconnection的讨论,并且超时至少有240秒.我的问题是,如果我通过NSURLConnection发送同步调用+(NSData*)sendSynchronousRequest:(NSURLRequest )请求returningResponse:(NSURLResponse*)响应错误:(NSError**)错误,有没有机会我可以在之前取消240秒了?我想也许设置一个计时器来取消这个同步请求,但我甚至不确定它是否可能?我在想:
[self performSelector:@selector(cancelRequest:) withObject:myRequest afterDelay:myTimeOut];
Run Code Online (Sandbox Code Playgroud)
我有一种感觉,如果请求已经发布,这将导致灾难,我无法确定.思考?有没有人试过这样做?这是同步通话.
我正在尝试使用SPARQL查询来检索有关DBpedia资源(Person)的信息.我想通过参数化资源URI使用相同的查询来检索有关任何Person的数据.由于特定资源可能不存在某些属性,因此我正在使用OPTIONAL语句.这是我的查询:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbpprop: <http://dbpedia.org/property/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT DISTINCT ?label ?abstract ?placeOfBirth
?birthPlace ?birthDate ?deathDate ?page ?thumbnail
WHERE {
<http://dbpedia.org/resource/Neil_Simon> rdfs:label ?label ;
dbo:abstract ?abstract ;
foaf:page ?page .
OPTIONAL {
<http://dbpedia.org/resource/Neil_Simon> dbpprop:placeOfBirth ?placeOfBirth ;
dbpprop:birthPlace ?birthPlace ;
dbo:birthDate ?birthDate ;
dbo:deathdate ?deathDate ;
dbo:thumbnail ?thumbnail .
}
FILTER (LANG(?label) = 'en')
FILTER (LANG(?abstract) = 'en')
}
LIMIT 1
Run Code Online (Sandbox Code Playgroud)
我在OPTIONAL中留下了除标签,摘要和页面之外的所有内容,因为如果我对另一个人使用相同的查询,则可能没有这些属性.问题是,结果中没有显示这些可选属性.在Neil Simon的案例中,您可以看到birthDate,birthPlace和缩略图的值:http://dbpedia.org/resource/Neil_Simon .但是,当我运行查询时,这些值不会显示:DBpedia SPARQL查询.我做错了什么,如何选择性地检索这些属性?
现在我正在创建一个数组并使用:
render :json => @comments
Run Code Online (Sandbox Code Playgroud)
这对于一个简单的JSON对象来说没什么问题,但是现在我的JSON对象需要几个帮助器,它们破坏了一切,并且需要在控制器中包含帮助器,这似乎会导致更多问题而不是解决.
那么,我如何在视图中创建这个JSON对象,在使用帮助器时我不必担心做任何事情或破坏任何东西.现在我在控制器中制作JSON对象的方式看起来像这样的东西?帮我把它迁移到一个视图:)
# Build the JSON Search Normalized Object
@comments = Array.new
@conversation_comments.each do |comment|
@comments << {
:id => comment.id,
:level => comment.level,
:content => html_format(comment.content),
:parent_id => comment.parent_id,
:user_id => comment.user_id,
:created_at => comment.created_at
}
end
render :json => @comments
Run Code Online (Sandbox Code Playgroud)
谢谢!
我已将Flurry(http://www.flurry.com/)整合到我的手机7应用程序中.所需的唯一代码是应用程序启动中的这一行
FlurryWP7SDK.Api.StartSession(ApiKeyValue);
Run Code Online (Sandbox Code Playgroud)
但是,只要该行被命中,应用程序就会发生KeyNotFoundException崩溃.堆栈跟踪包含在下面.它似乎是查询隔离的存储设置,并且当密钥不存在时失败.
有没有人有这个错误的经验,甚至成功地将乱舞集成到Phone 7应用程序?
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(String key)
at System.IO.IsolatedStorage.IsolatedStorageSettings.get_Item(String key)
at A.ca98fb38190f0d5cad84c67a779d17229.c204dba68825403c905efd7bfd067b17b(String ce0360de492f1f363775feaf6d6a8ced5, Object c8d4be677f7ee63f6756e13f285072523)
at A.c3f1105d518a239d73e2236200494de25.set_cfca54db015a16ab23de44b4d5c65e9a3(String c8d4be677f7ee63f6756e13f285072523)
at FlurryWP7SDK.Api.StartSession(String apiKey)
at AppName.App.Application_Launching(Object sender, LaunchingEventArgs e)
at Microsoft.Phone.Shell.PhoneApplicationService.FireLaunching()
at Microsoft.Phone.Execution.NativeEmInterop.FireOnLaunching()
Run Code Online (Sandbox Code Playgroud)
编辑
在与Flurry支持讨论之后,似乎Flurry代码捕获了KeyNotFoundException.但是,如果在抛出异常时要中断调试器设置,则无论如何都会进入调试器.然后继续执行将起作用,因为Flurry捕获并处理了异常.
我无法验证这是否是解决方案,因为我不再能够访问指示错误的开发环境,但它似乎是一个可能的解决方案.
我有一个包含三个webapps的Tomcat 6服务器:一个自定义的ROOT,Jenkins和Nexus.
我想使用BASIC身份验证来集中保护所有三个(server.xml?).
如何在不修改或配置Web应用程序的情况下实现此目的?
我需要创建一个套接字连接池,它将被提供给多个工作线程.是否有一个线程安全的对象池实现,其功能类似于Apache Commons GenericObjectPool?
public static void main(String[] args) {
int count, innerCount;
for(count=0;count<=3;count++)
{
System.out.println("Count is" + count);
for(innerCount=0; innerCount<count;innerCount++)
System.out.print("Hi, innerCount is"+ innerCount);
}
}
}
Run Code Online (Sandbox Code Playgroud)
输出:
计数为0
伯爵是1
嗨,innerCount是0Count是2
嗨,innerCount是0Hi,innerCount是1Count是3
嗨,innerCount是0Hi,innerCount是1Hi,innerCount是2
有人可以解释这个嵌套循环吗?当它是Count = 0和1时,为什么不打印出任何innerCounts?内部计数如何在Count旁边打印?谢谢.
c++ ×2
java ×2
actionview ×1
asp.net-mvc ×1
bookmarklet ×1
c#-4.0 ×1
dbpedia ×1
file ×1
flurry ×1
http ×1
image ×1
ios ×1
javascript ×1
json ×1
loops ×1
nsurlrequest ×1
session ×1
sparql ×1
tomcat ×1
tomcat6 ×1
vector ×1